tn3270lib
Python TN3270/TN3270E client for test automation (IBM-3278 models 2–5). Not an x3270 clone.
Documentation (intended Read the Docs project): https://tn3270lib.readthedocs.io
import tn3270lib
tn = tn3270lib.TN3270(device_type="IBM-3278-3", codepage="cp037")
tn.initiate("host", 23)
tn.wait_for_text("LOGON", timeout=10)
tn.fill("Userid", "IBMUSER")
tn.wait_unlock()
tn.send_enter()
tn.save_screen_html("screen.html")
print(tn.get_screen())
tn.disconnect()
Wait helpers: wait_for_text, wait_unlock, wait_cursor, wait_stable raise TN3270Timeout (screen, cursor, lock, last AID, raw records attached). Field helpers: fields(), field(label) (case-insensitive substring of the preceding protected text), fill, type, tab. Numeric unprotected fields (FA_NUMERIC) reject letters. codepage="cp273" etc.; extra IBM codecs: pip install tn3270lib[i18n]. EW uses the default 24×80 buffer; EWA switches to the model alternate (32×80 / 43×80 / 27×132). SFE/SA store per-cell color and highlighting; save_screen / save_screen_txt / save_screen_html dump the screen (HTML keeps protected vs unprotected and color spans). send_enter / send_pf / send_aid raise TN3270KeyboardLocked while locked and lock again after a successful AID.
TN3270E: BIND_IMAGE is parsed (raw + PLU/SLU/size hints on bind / bind_image); UNBIND clears it. FUNCTIONS advertised are RESPONSES and SYSREQ (not BIND_IMAGE-as-function, not SCS). sysreq() / send_aid('SYSREQ') send a TN3270E REQUEST and toggle SSCP-LU when SYSREQ was negotiated; otherwise the 3270 SYSREQ AID is used. In SSCP-LU mode, type + send_enter send DT_SSCP_LU_DATA (not Read Modified); get_sscp() returns inbound SSCP text. get_nvt() is an ASCII line buffer for DT_NVT and pre-3270 telnet bytes — not a full NVT terminal. Outbound 3270-DATA headers carry an incrementing 16-bit seq (IAC-doubled). Set Reply Mode is honored: field, extended-field (SFE on RM/RB), character (best-effort SA). reconnect() disconnects, resets 3270E/bind/buffers, and initiates again.
TLS defaults to CERT_NONE plus old ciphers for z/OS AT-TLS; verify=True is not the AT-TLS path. Use ssl_context= or certfile= / keyfile= for mTLS. require_tls=True refuses plaintext; allow_plaintext=True restores fallback. STARTTLS, SCS/3287 printer sessions, extra partitions, and DBCS are out of scope. Licensed GPL-3.0-or-later.
Install
From a checkout (the package is not assumed to be on PyPI yet):
pip install .
pip install '.[i18n]' # extra IBM SBCS codecs
pip install '.[docs]' # Sphinx / Read the Docs
When published:
pip install tn3270lib
pip install tn3270lib[i18n]
Build artifacts locally (no upload):
python3 -m pip install build twine
python3 -m build
python3 -m twine check dist/*
See CHANGELOG.md for 0.3.0 (parser fixes and phases A–C).
Metadata
Release files for tn3270lib 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tn3270lib-0.3.0.tar.gz | 61.2 kB | Without provenance | Details for tn3270lib-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tn3270lib-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for tn3270lib-0.3.0-py3-none-any.whl |
Total release size: 119.2 kB
Release files / tn3270lib-0.3.0.tar.gz
| Download URL | tn3270lib-0.3.0.tar.gz |
|---|---|
| Size | 61.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
163b61d6f857f172bdb0c5afc1f8972762079738591b82bab4589ccaec8a2624
|
|
BLAKE2b-256 checksum How to use checksums |
169156fc246a51759e2a8eda24820c0b06e47eccfd24346dfc3e7bcbb56d89a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.7
|
Release files / tn3270lib-0.3.0-py3-none-any.whl
| Download URL | tn3270lib-0.3.0-py3-none-any.whl |
|---|---|
| Size | 58.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
44806277b9abb8a5bcad4dd9f6bf06ddc5c0a4d3e63605012eb73dc1171a344e
|
|
BLAKE2b-256 checksum How to use checksums |
2bae50be92e4ceeb27eb8dd96c9ab7bdbeef0e883b356bb6ba419ce10ccd9ba8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.7
|
Security for tn3270lib 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.