Skip to content

Commit 484a322

Browse files
authored
Run vermin targetting at most Python 3.10 in CI (#2668)
* Run vermin targetting at most Python 3.10 in CI Run https://github.com/netromdk/vermin to verify we don't use any Python features of newer versions than what we want to support. * Fix getdents docs /home/runner/work/pwntools/pwntools/pwnlib/util/getdents.py:docstring of pwnlib.util.getdents.linux_dirent:5: ERROR: Unexpected indentation. [docutils] /home/runner/work/pwntools/pwntools/pwnlib/util/getdents.py:docstring of pwnlib.util.getdents.linux_dirent:9: WARNING: Block quote ends without a blank line; unexpected unindent. [docutils] /home/runner/work/pwntools/pwntools/pwnlib/util/getdents.py:docstring of pwnlib.util.getdents.linux_dirent:19: WARNING: Definition list ends without a blank line; unexpected unindent. [docutils] /home/runner/work/pwntools/pwntools/pwnlib/util/getdents.py:docstring of pwnlib.util.getdents.linux_dirent:24: ERROR: Unexpected indentation. [docutils] /home/runner/work/pwntools/pwntools/pwnlib/util/getdents.py:docstring of pwnlib.util.getdents.linux_dirent:34: WARNING: Block quote ends without a blank line; unexpected unindent. [docutils]
1 parent b20fa8b commit 484a322

File tree

3 files changed

+42
-40
lines changed

3 files changed

+42
-40
lines changed

.github/workflows/lint.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,8 @@ jobs:
3131
flake8 pwnlib setup.py docs travis --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
3232
flake8 examples --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --ignore='F403,F405'
3333
flake8 pwn --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --ignore='F401,F403,F405'
34+
35+
- name: Minimum Python version check
36+
run: |
37+
pip install vermin
38+
vermin -vvv --no-tips -t=3.10- --violations ./pwnlib ./pwn

pwnlib/constants/constant.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
try:
2-
base = long # workaround for py2
3-
except NameError:
4-
base = int
5-
6-
class Constant(base):
1+
class Constant(int):
72
def __new__(cls, s, i):
83
obj = super(Constant, cls).__new__(cls, i)
94
obj.s = s

pwnlib/util/getdents.py

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,40 +21,42 @@ class linux_dirent:
2121
"""
2222
Represent struct linux_dirent
2323
24-
struct linux_dirent
25-
{
26-
unsigned long d_ino;
27-
unsigned long d_off;
28-
unsigned short d_reclen;
29-
char d_name[];
30-
};
31-
// https://elixir.bootlin.com/linux/v6.14.4/source/fs/readdir.c#L244
32-
// the 32version of linux_dirent stores d_type after d_name
33-
34-
struct linux_dirent64 {
35-
u64 d_ino;
36-
s64 d_off;
37-
unsigned short d_reclen;
38-
unsigned char d_type;
39-
char d_name[];
40-
};
41-
// https://elixir.bootlin.com/linux/v6.14.4/source/include/linux/dirent.h#L5
42-
43-
enum
44-
{
45-
DT_UNKNOWN = 0,
46-
DT_FIFO = 1,
47-
DT_CHR = 2,
48-
DT_DIR = 4,
49-
DT_BLK = 6,
50-
DT_REG = 8,
51-
DT_LNK = 10,
52-
DT_SOCK = 12,
53-
DT_WHT = 14,
54-
DT_SUBVOL = 16
55-
};
56-
// https://elixir.bootlin.com/linux/v6.14.4/source/include/linux/fs_types.h#L42
57-
// https://elixir.bootlin.com/linux/v6.14.4/source/fs/bcachefs/dirent_format.h#L37
24+
.. code-block:: c
25+
26+
struct linux_dirent
27+
{
28+
unsigned long d_ino;
29+
unsigned long d_off;
30+
unsigned short d_reclen;
31+
char d_name[];
32+
};
33+
// https://elixir.bootlin.com/linux/v6.14.4/source/fs/readdir.c#L244
34+
// the 32version of linux_dirent stores d_type after d_name
35+
36+
struct linux_dirent64 {
37+
u64 d_ino;
38+
s64 d_off;
39+
unsigned short d_reclen;
40+
unsigned char d_type;
41+
char d_name[];
42+
};
43+
// https://elixir.bootlin.com/linux/v6.14.4/source/include/linux/dirent.h#L5
44+
45+
enum
46+
{
47+
DT_UNKNOWN = 0,
48+
DT_FIFO = 1,
49+
DT_CHR = 2,
50+
DT_DIR = 4,
51+
DT_BLK = 6,
52+
DT_REG = 8,
53+
DT_LNK = 10,
54+
DT_SOCK = 12,
55+
DT_WHT = 14,
56+
DT_SUBVOL = 16
57+
};
58+
// https://elixir.bootlin.com/linux/v6.14.4/source/include/linux/fs_types.h#L42
59+
// https://elixir.bootlin.com/linux/v6.14.4/source/fs/bcachefs/dirent_format.h#L37
5860
"""
5961

6062
d_ino: int

0 commit comments

Comments
 (0)