https://github.com/lukesavefrogs/jython21-backport
Backporting of some newer Python features down to Jython 2.1
https://github.com/lukesavefrogs/jython21-backport
jython legacy-python polyfill python python-legacy python2
Last synced: 3 months ago
JSON representation
Backporting of some newer Python features down to Jython 2.1
- Host: GitHub
- URL: https://github.com/lukesavefrogs/jython21-backport
- Owner: LukeSavefrogs
- License: mit
- Created: 2023-05-12T08:31:27.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-11-13T14:48:45.000Z (7 months ago)
- Last Synced: 2025-12-13T04:09:17.489Z (6 months ago)
- Topics: jython, legacy-python, polyfill, python, python-legacy, python2
- Language: Python
- Homepage:
- Size: 150 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Jython 2.1 backporting
[](https://github.com/LukeSavefrogs/jython21-backport/actions/workflows/run-python-tests-lin.yml)
[](https://github.com/LukeSavefrogs/jython21-backport/actions/workflows/run-python-tests-mac.yml)
[](https://github.com/LukeSavefrogs/jython21-backport/actions/workflows/run-python-tests-win.yml)
[](https://github.com/LukeSavefrogs/jython21-backport/actions/workflows/run-jython-tests-lin.yml)
[](https://github.com/LukeSavefrogs/jython21-backport/actions/workflows/run-jython-tests-mac.yml)
[](https://github.com/LukeSavefrogs/jython21-backport/actions/workflows/run-jython-tests-win.yml)
Collection of features present in **newer Python** versions (`v2.x`, `v3.x`) backported to **legacy Python versions** (tested down to `v2.1`).
Supported Python implementation:
- [**CPython**](https://www.python.org/)
- [**Jython**](https://www.jython.org/)
## Features
This package provides backporting for the following features:
- [**`pathlib.Path()`**](src/polyfills/pathlib/) class (`Python>=3.4`)
- [**`bool()`**](src/polyfills/stdlib/future_types/) class (`Python>=2.3`) as well as `True` and `False` ([`Python>=2.3`](https://giedrius.blog/2018/01/04/what-is-actually-true-and-false-in-python/))
- [**`dict()`**](src/polyfills/stdlib/future_types/) class
- [**`sorted()`**](src/polyfills/stdlib/) function (`Python>=2.4`)
- [**`sum()`**](src/polyfills/stdlib/) function (`Python>=2.3`)
- [**`collections.OrderedDict()`**](src/polyfills/collections/) (`Python>=2.7`)
- [**`json`**](src/polyfills/json/) module (`Python>=2.6`)
- [**`logging`**](src/polyfills/logging/) module (`Python>=2.3`)
- [**`itertools`**](src/polyfills/itertools/) module (`Python>=2.3`)
- [**`set()`**](src/polyfills/stdlib/sets.py) class (`sets` module `Python>=2.3`, standard library `Python>=2.4`)
- [**`print()`**](src/polyfills/stdlib/) function (keyword arguments such as `end` or `sep` were added in `Python 3.3`, see module docstring for more details)
## Tests
After performing a change to a module it's best practice to **always run tests** and update those failing (or add some if it's a new feature).
### All repository
To run all the tests in this repository use the following command:
```shell
poetry run python -m unittest discover ./src/
```
You can test single files using the following commands:
### Single module
#### Locally
When developing using `poetry` use the following command:
```shell
poetry run python /path/to/module.py
```
For example:
```shell
(polyfills-py3.9) → ~\polyfills › poetry run python .\src\polyfills\pathlib\__init__.py
..........
----------------------------------------------------------------------
Ran 10 tests in 0.004s
OK
```
#### Remotely
To run tests on a host running the Websphere Application Server Jython console (`wsadmin.sh`) run the following command:
```shell
/path/to/profile/bin/wsadmin.sh -lang jython -f /path/to/module.py
```
For example:
```shell
username@hostname ~ $ /opt/Websphere/MyCell/profiles/dmgr/bin/wsadmin.sh -lang jython -f /src/polyfills/pathlib/__init__.py
WASX7209I: Connected to process "dmgr" on node MyNode using SOAP connector; The type of process is: DeploymentManager
..........
----------------------------------------------------------------------
Ran 10 tests in 0.068s
OK
```