Skip to content

Commit a5e448e

Browse files
committed
[GR-44958] Add patch for charset_normalizer 3.1.0
PullRequest: graalpython/2684
2 parents 06593ac + e5ebcc2 commit a5e448e

File tree

8 files changed

+97
-31
lines changed

8 files changed

+97
-31
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ implementation is made available for experimentation and curious end-users.
1313

1414
The easiest option to try GraalPy is
1515
[Pyenv](https://github.com/pyenv/pyenv/), the Python version manager. It allows
16-
you to easily install different GraalPy releases. To get version 21.2.0, for
17-
example, just run `pyenv install graalpy-21.2.0`.
16+
you to easily install different GraalPy releases. To get version 22.3.0, for
17+
example, just run `pyenv install graalpy-22.3.0`.
1818

1919
To try GraalPy with a full GraalVM, including the support for Java embedding
2020
and interop with other languages, you can use the bundled releases from

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,10 @@ int open(VirtualFrame frame, PosixPath path, int flags, int mode, int dirFd,
603603
@Cached SysModuleBuiltins.AuditNode auditNode,
604604
@Cached BranchProfile errorProfile,
605605
@Cached GilNode gil) {
606-
int fixedFlags = flags | O_CLOEXEC.value;
606+
int fixedFlags = flags;
607+
if (O_CLOEXEC.defined) {
608+
fixedFlags |= O_CLOEXEC.getValueIfDefined();
609+
}
607610
auditNode.audit("open", path.originalObject, PNone.NONE, fixedFlags);
608611
gil.release(true);
609612
try {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/EmulatedPosixSupport.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
import static com.oracle.graal.python.runtime.PosixConstants.NI_NAMEREQD;
7878
import static com.oracle.graal.python.runtime.PosixConstants.NI_NUMERICHOST;
7979
import static com.oracle.graal.python.runtime.PosixConstants.NI_NUMERICSERV;
80-
import static com.oracle.graal.python.runtime.PosixConstants.O_ACCMODE;
8180
import static com.oracle.graal.python.runtime.PosixConstants.O_APPEND;
8281
import static com.oracle.graal.python.runtime.PosixConstants.O_CREAT;
8382
import static com.oracle.graal.python.runtime.PosixConstants.O_DIRECT;
@@ -4168,7 +4167,7 @@ private static Set<PosixFilePermission> modeToPosixFilePermissions(int fileMode)
41684167
@TruffleBoundary(allowInlining = true)
41694168
private static Set<StandardOpenOption> flagsToOptions(int flags) {
41704169
Set<StandardOpenOption> options = new HashSet<>();
4171-
int maskedFlags = flags & O_ACCMODE.value;
4170+
int maskedFlags = flags & (O_RDONLY.value | O_WRONLY.value | O_RDWR.value);
41724171
if ((flags & O_APPEND.value) != 0) {
41734172
options.add(StandardOpenOption.WRITE);
41744173
options.add(StandardOpenOption.APPEND);
@@ -4197,10 +4196,10 @@ private static Set<StandardOpenOption> flagsToOptions(int flags) {
41974196
options.add(StandardOpenOption.WRITE);
41984197
options.add(StandardOpenOption.CREATE_NEW);
41994198
}
4200-
if ((flags & O_NDELAY.value) != 0 || (O_DIRECT.defined && (flags & O_DIRECT.getValueIfDefined()) != 0)) {
4199+
if ((O_NDELAY.defined && (flags & O_NDELAY.getValueIfDefined()) != 0) || (O_DIRECT.defined && (flags & O_DIRECT.getValueIfDefined()) != 0)) {
42014200
options.add(StandardOpenOption.DSYNC);
42024201
}
4203-
if ((flags & O_SYNC.value) != 0) {
4202+
if (O_SYNC.defined && (flags & O_SYNC.getValueIfDefined()) != 0) {
42044203
options.add(StandardOpenOption.SYNC);
42054204
}
42064205
if ((flags & O_TRUNC.value) != 0) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PosixConstants.java

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,34 @@ public final class PosixConstants {
9797
public static final OptionalIntConstant SEEK_HOLE;
9898
public static final MandatoryIntConstant SOMAXCONN;
9999
public static final OptionalIntConstant PIPE_BUF;
100-
public static final MandatoryIntConstant O_ACCMODE;
100+
public static final OptionalIntConstant O_ACCMODE;
101101
public static final MandatoryIntConstant O_RDONLY;
102102
public static final MandatoryIntConstant O_WRONLY;
103103
public static final MandatoryIntConstant O_RDWR;
104104
public static final MandatoryIntConstant O_CREAT;
105105
public static final MandatoryIntConstant O_EXCL;
106106
public static final MandatoryIntConstant O_TRUNC;
107107
public static final MandatoryIntConstant O_APPEND;
108-
public static final MandatoryIntConstant O_NONBLOCK;
109-
public static final MandatoryIntConstant O_NDELAY;
110-
public static final MandatoryIntConstant O_DSYNC;
111-
public static final MandatoryIntConstant O_CLOEXEC;
112-
public static final MandatoryIntConstant O_SYNC;
108+
public static final OptionalIntConstant O_NONBLOCK;
109+
public static final OptionalIntConstant O_NOCTTY;
110+
public static final OptionalIntConstant O_NDELAY;
111+
public static final OptionalIntConstant O_DSYNC;
112+
public static final OptionalIntConstant O_CLOEXEC;
113+
public static final OptionalIntConstant O_SYNC;
113114
public static final OptionalIntConstant O_DIRECT;
114115
public static final OptionalIntConstant O_RSYNC;
115116
public static final OptionalIntConstant O_TMPFILE;
116117
public static final OptionalIntConstant O_DIRECTORY;
118+
public static final OptionalIntConstant O_BINARY;
119+
public static final OptionalIntConstant O_TEXT;
120+
public static final OptionalIntConstant O_XATTR;
121+
public static final OptionalIntConstant O_LARGEFILE;
122+
public static final OptionalIntConstant O_SHLOCK;
123+
public static final OptionalIntConstant O_EXLOCK;
124+
public static final OptionalIntConstant O_EXEC;
125+
public static final OptionalIntConstant O_SEARCH;
126+
public static final OptionalIntConstant O_PATH;
127+
public static final OptionalIntConstant O_TTY_INIT;
117128
public static final MandatoryIntConstant S_IFMT;
118129
public static final MandatoryIntConstant S_IFSOCK;
119130
public static final MandatoryIntConstant S_IFLNK;
@@ -350,23 +361,34 @@ public final class PosixConstants {
350361
SEEK_HOLE = reg.createOptionalInt("SEEK_HOLE");
351362
SOMAXCONN = reg.createMandatoryInt("SOMAXCONN");
352363
PIPE_BUF = reg.createOptionalInt("PIPE_BUF");
353-
O_ACCMODE = reg.createMandatoryInt("O_ACCMODE");
364+
O_ACCMODE = reg.createOptionalInt("O_ACCMODE");
354365
O_RDONLY = reg.createMandatoryInt("O_RDONLY");
355366
O_WRONLY = reg.createMandatoryInt("O_WRONLY");
356367
O_RDWR = reg.createMandatoryInt("O_RDWR");
357368
O_CREAT = reg.createMandatoryInt("O_CREAT");
358369
O_EXCL = reg.createMandatoryInt("O_EXCL");
359370
O_TRUNC = reg.createMandatoryInt("O_TRUNC");
360371
O_APPEND = reg.createMandatoryInt("O_APPEND");
361-
O_NONBLOCK = reg.createMandatoryInt("O_NONBLOCK");
362-
O_NDELAY = reg.createMandatoryInt("O_NDELAY");
363-
O_DSYNC = reg.createMandatoryInt("O_DSYNC");
364-
O_CLOEXEC = reg.createMandatoryInt("O_CLOEXEC");
365-
O_SYNC = reg.createMandatoryInt("O_SYNC");
372+
O_NONBLOCK = reg.createOptionalInt("O_NONBLOCK");
373+
O_NOCTTY = reg.createOptionalInt("O_NOCTTY");
374+
O_NDELAY = reg.createOptionalInt("O_NDELAY");
375+
O_DSYNC = reg.createOptionalInt("O_DSYNC");
376+
O_CLOEXEC = reg.createOptionalInt("O_CLOEXEC");
377+
O_SYNC = reg.createOptionalInt("O_SYNC");
366378
O_DIRECT = reg.createOptionalInt("O_DIRECT");
367379
O_RSYNC = reg.createOptionalInt("O_RSYNC");
368380
O_TMPFILE = reg.createOptionalInt("O_TMPFILE");
369381
O_DIRECTORY = reg.createOptionalInt("O_DIRECTORY");
382+
O_BINARY = reg.createOptionalInt("O_BINARY");
383+
O_TEXT = reg.createOptionalInt("O_TEXT");
384+
O_XATTR = reg.createOptionalInt("O_XATTR");
385+
O_LARGEFILE = reg.createOptionalInt("O_LARGEFILE");
386+
O_SHLOCK = reg.createOptionalInt("O_SHLOCK");
387+
O_EXLOCK = reg.createOptionalInt("O_EXLOCK");
388+
O_EXEC = reg.createOptionalInt("O_EXEC");
389+
O_SEARCH = reg.createOptionalInt("O_SEARCH");
390+
O_PATH = reg.createOptionalInt("O_PATH");
391+
O_TTY_INIT = reg.createOptionalInt("O_TTY_INIT");
370392
S_IFMT = reg.createMandatoryInt("S_IFMT");
371393
S_IFSOCK = reg.createMandatoryInt("S_IFSOCK");
372394
S_IFLNK = reg.createMandatoryInt("S_IFLNK");
@@ -558,8 +580,8 @@ public final class PosixConstants {
558580
OFFSETOF_STRUCT_SOCKADDR_UN_SUN_PATH = reg.createMandatoryInt("OFFSETOF_STRUCT_SOCKADDR_UN_SUN_PATH");
559581
SIZEOF_STRUCT_SOCKADDR_UN_SUN_PATH = reg.createMandatoryInt("SIZEOF_STRUCT_SOCKADDR_UN_SUN_PATH");
560582

561-
openFlags = new IntConstant[]{O_ACCMODE, O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, O_EXCL, O_TRUNC, O_APPEND, O_NONBLOCK, O_NDELAY, O_DSYNC, O_CLOEXEC, O_SYNC, O_DIRECT, O_RSYNC, O_TMPFILE,
562-
O_DIRECTORY};
583+
openFlags = new IntConstant[]{O_ACCMODE, O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, O_EXCL, O_TRUNC, O_APPEND, O_NONBLOCK, O_NOCTTY, O_NDELAY, O_DSYNC, O_CLOEXEC, O_SYNC, O_DIRECT, O_RSYNC,
584+
O_TMPFILE, O_DIRECTORY, O_BINARY, O_TEXT, O_XATTR, O_LARGEFILE, O_SHLOCK, O_EXLOCK, O_EXEC, O_SEARCH, O_PATH, O_TTY_INIT};
563585
fileType = new IntConstant[]{S_IFMT, S_IFSOCK, S_IFLNK, S_IFREG, S_IFBLK, S_IFDIR, S_IFCHR, S_IFIFO};
564586
mmapFlags = new IntConstant[]{MAP_SHARED, MAP_PRIVATE, MAP_ANONYMOUS, MAP_DENYWRITE, MAP_EXECUTABLE};
565587
mmapProtection = new IntConstant[]{PROT_NONE, PROT_READ, PROT_WRITE, PROT_EXEC};

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PosixConstantsDarwin.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
*/
4141
package com.oracle.graal.python.runtime;
4242

43-
// Auto generated by gen_native_cfg.py at 2023-02-16 18:27:17.595009
44-
// on Darwin ol-mac-mini2-prague.cz.oracle.com 21.6.0 Darwin Kernel Version 21.6.0: Mon Dec 19 20:44:01 PST 2022; root:xnu-8020.240.18~2/RELEASE_X86_64 x86_64 i386
43+
// Auto generated by gen_native_cfg.py at 2023-03-16 07:20:43.880000
44+
// on Darwin some-user.local 21.6.0 Darwin Kernel Version 21.6.0: Mon Dec 19 20:44:01 PST 2022; root:xnu-8020.240.18~2/RELEASE_X86_64 x86_64 i386
4545
class PosixConstantsDarwin {
4646

4747
private PosixConstantsDarwin() {
@@ -77,6 +77,7 @@ static void getConstants(PosixConstants.Registry constants) {
7777
constants.put("O_TRUNC", 0x00000400);
7878
constants.put("O_APPEND", 0x00000008);
7979
constants.put("O_NONBLOCK", 0x00000004);
80+
constants.put("O_NOCTTY", 0x00020000);
8081
constants.put("O_NDELAY", 0x00000004);
8182
constants.put("O_DSYNC", 0x00400000);
8283
constants.put("O_CLOEXEC", 0x01000000);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PosixConstantsLinux.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
*/
4141
package com.oracle.graal.python.runtime;
4242

43-
// Auto generated by gen_native_cfg.py at 2023-02-15 17:36:59.628778
44-
// on Linux arisu 6.1.10-200.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Feb 6 23:56:48 UTC 2023 x86_64 x86_64
43+
// Auto generated by gen_native_cfg.py at 2023-03-17 10:24:55.349775
44+
// on Linux arisu 6.1.18-200.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Mar 11 16:09:14 UTC 2023 x86_64 x86_64
4545
class PosixConstantsLinux {
4646

4747
private PosixConstantsLinux() {
@@ -78,6 +78,7 @@ static void getConstants(PosixConstants.Registry constants) {
7878
constants.put("O_TRUNC", 0x00000200);
7979
constants.put("O_APPEND", 0x00000400);
8080
constants.put("O_NONBLOCK", 0x00000800);
81+
constants.put("O_NOCTTY", 0x00000100);
8182
constants.put("O_NDELAY", 0x00000800);
8283
constants.put("O_DSYNC", 0x00001000);
8384
constants.put("O_CLOEXEC", 0x00080000);
@@ -86,6 +87,8 @@ static void getConstants(PosixConstants.Registry constants) {
8687
constants.put("O_RSYNC", 0x00101000);
8788
constants.put("O_TMPFILE", 0x00410000);
8889
constants.put("O_DIRECTORY", 0x00010000);
90+
constants.put("O_LARGEFILE", 0x00000000);
91+
constants.put("O_PATH", 0x00200000);
8992
constants.put("S_IFMT", 0x0000F000);
9093
constants.put("S_IFSOCK", 0x0000C000);
9194
constants.put("S_IFLNK", 0x0000A000);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
diff --git a/charset_normalizer/utils.py b/charset_normalizer/utils.py
2+
index dcb14df..12079e3 100644
3+
--- a/charset_normalizer/utils.py
4+
+++ b/charset_normalizer/utils.py
5+
@@ -11,7 +11,10 @@ from functools import lru_cache
6+
from re import findall
7+
from typing import List, Optional, Set, Tuple, Union
8+
9+
-from _multibytecodec import MultibyteIncrementalDecoder
10+
+try:
11+
+ from _multibytecodec import MultibyteIncrementalDecoder
12+
+except ImportError:
13+
+ MultibyteIncrementalDecoder = None
14+
15+
from .constant import (
16+
ENCODING_MARKS,
17+
@@ -244,7 +247,7 @@ def is_multi_byte_encoding(name: str) -> bool:
18+
} or issubclass(
19+
importlib.import_module("encodings.{}".format(name)).IncrementalDecoder, # type: ignore
20+
MultibyteIncrementalDecoder,
21+
- )
22+
+ ) if MultibyteIncrementalDecoder else False
23+
24+
25+
def identify_sig_or_bom(sequence: bytes) -> Tuple[Optional[str], bytes]:
26+
--
27+
3.1.0

scripts/gen_native_cfg.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,23 +142,34 @@
142142
* i PIPE_BUF
143143
144144
[openFlags]
145-
0 x O_ACCMODE
145+
* x O_ACCMODE
146146
x O_RDONLY
147147
x O_WRONLY
148148
x O_RDWR
149149
x O_CREAT
150150
x O_EXCL
151151
x O_TRUNC
152152
x O_APPEND
153-
0 x O_NONBLOCK
154-
0 x O_NDELAY
155-
0 x O_DSYNC
156-
0 x O_CLOEXEC
157-
0 x O_SYNC
153+
* x O_NONBLOCK
154+
* x O_NOCTTY
155+
* x O_NDELAY
156+
* x O_DSYNC
157+
* x O_CLOEXEC
158+
* x O_SYNC
158159
* x O_DIRECT
159160
* x O_RSYNC
160161
* x O_TMPFILE
161162
* x O_DIRECTORY
163+
* x O_BINARY
164+
* x O_TEXT
165+
* x O_XATTR
166+
* x O_LARGEFILE
167+
* x O_SHLOCK
168+
* x O_EXLOCK
169+
* x O_EXEC
170+
* x O_SEARCH
171+
* x O_PATH
172+
* x O_TTY_INIT
162173
163174
[fileType]
164175
u x S_IFMT

0 commit comments

Comments
 (0)