Skip to content

Commit

Permalink
add support for python 3.12 (fixes #4446)
Browse files Browse the repository at this point in the history
  • Loading branch information
GammaC0de committed Apr 14, 2024
1 parent cf528f8 commit 1da386c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .github/scripts/install_pycurl_win.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ case "$1" in
"3.11")
WHEEL_FILE="pycurl-7.45.1-cp311-cp311-win_amd64.whl"
;;
"3.12")
WHEEL_FILE="pycurl-7.45.2-cp312-cp312-win_amd64.whl"
;;
*)
echo "::error::Unsupported Python version"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-20.04, macos-latest, windows-latest]
include:
- python-version: pypy-3.6
Expand Down
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ classifiers =
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
Topic :: Communications
Expand Down Expand Up @@ -77,7 +78,8 @@ install_requires =
cryptography>=35.0.0;platform_python_implementation!="PyPy"
cryptography>=35.0.0,<40.0.0;platform_python_implementation=='PyPy'
filetype~=1.0
Js2Py~=0.7
Js2Py~=0.7;python_version<"3.12"
dukPy>=0.3.1;python_version>="3.12"
pycurl~=7.43
certifi
# requests-html~=0.10
Expand Down
15 changes: 10 additions & 5 deletions src/pyload/core/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

import random
import string
import sys

import js2py

js2py.disable_pyimport()
if sys.version_info < (3, 12):
import js2py
js2py.disable_pyimport()
else:
import dukpy


def random_string(length):
Expand All @@ -22,8 +25,10 @@ def is_plural(value):


def eval_js(script, es6=False):
# return requests_html.HTML().render(script=script, reload=False)
return (js2py.eval_js6 if es6 else js2py.eval_js)(script)
if sys.version_info < (3, 12):
return (js2py.eval_js6 if es6 else js2py.eval_js)(script)
else:
return dukpy.evaljs(script)


def accumulate(iterable, to_map=None):
Expand Down

0 comments on commit 1da386c

Please sign in to comment.