Skip to content

Commit 9f20945

Browse files
Merge branch '3.13' into backport-53b0498-3.13
2 parents 9dbcb31 + 99c765a commit 9f20945

22 files changed

Lines changed: 1493 additions & 293 deletions

Doc/library/string.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,8 @@ attributes:
943943

944944
Alternatively, you can provide the entire regular expression pattern by
945945
overriding the class attribute *pattern*. If you do this, the value must be a
946-
regular expression object with four named capturing groups. The capturing
946+
regular expression pattern string, or a compiled regular expression
947+
object, with four named capturing groups. The capturing
947948
groups correspond to the rules given above, along with the invalid placeholder
948949
rule:
949950

Include/internal/pycore_pylifecycle.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@ extern int _Py_LegacyLocaleDetected(int warn);
111111
// Export for 'readline' shared extension
112112
PyAPI_FUNC(char*) _Py_SetLocaleFromEnv(int category);
113113

114-
// Export for special main.c string compiling with source tracebacks
115-
int _PyRun_SimpleStringFlagsWithName(const char *command, const char* name, PyCompilerFlags *flags);
116-
117114

118115
/* interpreter config */
119116

Include/internal/pycore_pythonrun.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,32 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11-
extern int _PyRun_SimpleFileObject(
11+
extern PyObject* _PyRun_SimpleFile(
1212
FILE *fp,
1313
PyObject *filename,
1414
int closeit,
1515
PyCompilerFlags *flags);
1616

17-
extern int _PyRun_AnyFileObject(
17+
extern PyObject* _PyRun_AnyFile(
1818
FILE *fp,
1919
PyObject *filename,
2020
int closeit,
2121
PyCompilerFlags *flags);
2222

23-
extern int _PyRun_InteractiveLoopObject(
24-
FILE *fp,
25-
PyObject *filename,
26-
PyCompilerFlags *flags);
27-
2823
extern const char* _Py_SourceAsString(
2924
PyObject *cmd,
3025
const char *funcname,
3126
const char *what,
3227
PyCompilerFlags *cf,
3328
PyObject **cmd_copy);
3429

30+
// Export for special main.c string compiling with source tracebacks
31+
extern PyObject* _PyRun_SimpleString(
32+
const char *command,
33+
PyObject* name,
34+
PyCompilerFlags *flags);
35+
36+
3537
#ifdef __cplusplus
3638
}
3739
#endif

Lib/email/utils.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,13 @@ def parsedate_to_datetime(data):
317317
if parsed_date_tz is None:
318318
raise ValueError('Invalid date value or format "%s"' % str(data))
319319
*dtuple, tz = parsed_date_tz
320-
if tz is None:
321-
return datetime.datetime(*dtuple[:6])
322-
return datetime.datetime(*dtuple[:6],
323-
tzinfo=datetime.timezone(datetime.timedelta(seconds=tz)))
320+
try:
321+
if tz is None:
322+
return datetime.datetime(*dtuple[:6])
323+
return datetime.datetime(*dtuple[:6],
324+
tzinfo=datetime.timezone(datetime.timedelta(seconds=tz)))
325+
except OverflowError as exc:
326+
raise ValueError('Invalid date value or format "%s"' % str(data)) from exc
324327

325328

326329
def parseaddr(addr, *, strict=True):

Lib/imaplib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ def select(self, mailbox='INBOX', readonly=False):
797797
if __debug__:
798798
if self.debug >= 1:
799799
self._dump_ur(self.untagged_responses)
800-
raise self.readonly('%s is not writable' % mailbox)
800+
raise self.readonly('%r is not writable' % (mailbox,))
801801
return typ, self.untagged_responses.get('EXISTS', [None])
802802

803803

@@ -921,7 +921,7 @@ def uid(self, command, *args):
921921
"""
922922
command = command.upper()
923923
if not command in Commands:
924-
raise self.error("Unknown IMAP4 UID command: %s" % command)
924+
raise self.error("Unknown IMAP4 UID command: %r" % (command,))
925925
if self.state not in Commands[command]:
926926
raise self.error("command %s illegal in state %s, "
927927
"only allowed in states %s" %

Lib/string.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ def __init_subclass__(cls):
7070
super().__init_subclass__()
7171
if 'pattern' in cls.__dict__:
7272
pattern = cls.pattern
73+
if isinstance(pattern, _re.Pattern):
74+
# An already-compiled pattern (which the documentation allows)
75+
# is used as-is; re.compile() rejects flags on a compiled
76+
# pattern.
77+
return
7378
else:
7479
delim = _re.escape(cls.delimiter)
7580
id = cls.idpattern

0 commit comments

Comments
 (0)