Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check-code-and-run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10"] # ["2.7", "3.6", "3.10"]
python-version: ["3.10", "3.13"] # ["2.7", "3.6", "3.10"]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion bin/monkeylord.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def save_config(path):

def load_config(path):
"""load the config from path"""
with open(path, "rU") as f:
with open(path, "r") as f:
tl = json.load(f)
patches.PATCHES["ALL"].disable()
for k in sorted(tl): # sort is important to load groups first
Expand Down
15 changes: 13 additions & 2 deletions core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

__version__ = "0.7.5"

import imp as pyimp # rename to avoid name conflict with objc_util
import importlib
import logging
import logging.handlers
import os
Expand Down Expand Up @@ -101,6 +101,17 @@
pass


def load_source(modname, filename):
loader = importlib.machinery.SourceFileLoader(modname, filename)
spec = importlib.util.spec_from_file_location(modname, filename, loader=loader)
module = importlib.util.module_from_spec(spec)
# The module is always executed and not cached in sys.modules.
# Uncomment the following line to cache the module.
# sys.modules[module.__name__] = module
loader.exec_module(module)
return module


class StaSh(object):
"""
Main application class. It initialize and wires the components and provide
Expand Down Expand Up @@ -292,7 +303,7 @@ def _load_lib(self):
"Attempting to load library '{}'...".format(name)
)
try:
self.__dict__[name] = pyimp.load_source(name, fp)
self.__dict__[name] = load_source(name, fp)
except Exception as e:
self.write_message(
"%s: failed to load library file (%s)" % (f, repr(e)),
Expand Down
2 changes: 1 addition & 1 deletion getstash.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def setup_install(
"__name__": "__main__",
"__file__": fp,
}
with open(fp, "rU") as fin:
with open(fp, "r") as fin:
content = fin.read()
code = compile(content, fp, "exec", dont_inherit=True)
exec(code, ns, ns)
Expand Down
11 changes: 6 additions & 5 deletions lib/mlpatches/base.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-
"""This module contains the base class for patches."""

import sys
import imp
import importlib
import os
import sys

from stash.core import load_source
from stashutils.core import get_stash

SKIP = "<skip>' # indicate that this patch should be skipped.'"
Expand Down Expand Up @@ -98,9 +99,9 @@ def do_enable(self):
):
raise ValueError("Invalid Patch definition!")
if self.module not in sys.modules:
fin, path, description = imp.find_module(self.module)
fin, path, description = importlib.find_module(self.module)
try:
module = imp.load_module(self.module, fin, path, description)
module = importlib.load_module(self.module, fin, path, description)
finally:
fin.close()
else:
Expand Down Expand Up @@ -139,7 +140,7 @@ def do_enable(self):
if self.name in sys.modules:
del sys.modules[self.name]
with open(self.path, "r") as f:
nmod = imp.load_source(self.name, self.path, f)
nmod = load_source(self.name, self.path, f)
sys.modules[self.name] = nmod

def do_disable(self):
Expand Down
2 changes: 1 addition & 1 deletion lib/mlpatches/modules/subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def __init__(
self.cmd = l2c.list2cmdline(args)

# === setup std* ===
rfm = "rU" if universal_newlines else "rb"
rfm = "r" if universal_newlines else "rb"
# setup stdout
if stdout is None:
# use own stdout
Expand Down
4 changes: 2 additions & 2 deletions lib/stashutils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"""core utilities for StaSh-scripts"""

import threading
import imp
import os

from stash.core import load_source
from stash.system import shthreads


Expand Down Expand Up @@ -37,7 +37,7 @@ def load_from_dir(dirpath, varname):
if not os.path.isfile(fp):
continue
with open(fp, "r") as fin:
mod = imp.load_source(fn[: fn.index(".")], fp, fin)
mod = load_source(fn[: fn.index(".")], fp, fin)
if not hasattr(mod, varname):
continue
else:
Expand Down
2 changes: 1 addition & 1 deletion lib/stashutils/fsi/DropBox.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def isfile(self, name):
def open(self, name, mode="rb", buffering=0):
mode = mode.replace("+", "")
ap = self.abspath(name)
if mode in ("r", "rb", "rU"):
if mode in ("r", "rb"):
try:
response = self.client.files_download(ap)[1]
# unfortunaly, we cant return response.raw because it does not
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"requests",
"pycrypto",
"pyte",
"standard-imghdr",
],
)
TEST_REQUIREMENTS = [
Expand Down
2 changes: 1 addition & 1 deletion tests/stashtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from stash.system.shcommon import _STASH_ROOT, PY3


ON_TRAVIS = "TRAVIS" in os.environ
ON_TRAVIS = "CI" in os.environ


def network_is_available():
Expand Down
Loading