Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4272101

Browse files
authored
Merge branch 'main' into TurtleTeleportMethod
2 parents 8db9bf3 + 79b9db9 commit 4272101

4 files changed

Lines changed: 29 additions & 16 deletions

File tree

Include/internal/pycore_code.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ extern int _PyLineTable_PreviousAddressRange(PyCodeAddressRange *range);
226226

227227
/* Specialization functions */
228228

229-
extern void _Py_Specialize_LoadSuperAttr(PyObject *global_super, PyObject *class, PyObject *self,
229+
extern void _Py_Specialize_LoadSuperAttr(PyObject *global_super, PyObject *cls, PyObject *self,
230230
_Py_CODEUNIT *instr, PyObject *name, int load_method);
231231
extern void _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr,
232232
PyObject *name);

Lib/test/test_patma.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3165,6 +3165,19 @@ def f(command): # 0
31653165
self.assertListEqual(self._trace(f, "go x"), [1, 2, 3])
31663166
self.assertListEqual(self._trace(f, "spam"), [1, 2, 3])
31673167

3168+
def test_unreachable_code(self):
3169+
def f(command): # 0
3170+
match command: # 1
3171+
case 1: # 2
3172+
if False: # 3
3173+
return 1 # 4
3174+
case _: # 5
3175+
if False: # 6
3176+
return 0 # 7
3177+
3178+
self.assertListEqual(self._trace(f, 1), [1, 2, 3])
3179+
self.assertListEqual(self._trace(f, 0), [1, 2, 5, 6])
3180+
31683181
def test_parser_deeply_nested_patterns(self):
31693182
# Deeply nested patterns can cause exponential backtracking when parsing.
31703183
# See gh-93671 for more information.

Modules/_datetimemodule.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5144,13 +5144,13 @@ datetime_datetime_now_impl(PyTypeObject *type, PyObject *tz)
51445144
static PyObject *
51455145
datetime_utcnow(PyObject *cls, PyObject *dummy)
51465146
{
5147-
PyErr_WarnEx(
5148-
PyExc_DeprecationWarning,
5149-
"datetime.utcnow() is deprecated and scheduled for removal in a future "
5150-
"version. Use timezone-aware objects to represent datetimes in UTC: "
5151-
"datetime.now(datetime.UTC).",
5152-
2
5153-
);
5147+
if (PyErr_WarnEx(PyExc_DeprecationWarning,
5148+
"datetime.utcnow() is deprecated and scheduled for removal in a "
5149+
"future version. Use timezone-aware objects to represent datetimes "
5150+
"in UTC: datetime.now(datetime.UTC).", 2))
5151+
{
5152+
return NULL;
5153+
}
51545154
return datetime_best_possible(cls, _PyTime_gmtime, Py_None);
51555155
}
51565156

@@ -5187,13 +5187,13 @@ datetime_fromtimestamp(PyObject *cls, PyObject *args, PyObject *kw)
51875187
static PyObject *
51885188
datetime_utcfromtimestamp(PyObject *cls, PyObject *args)
51895189
{
5190-
PyErr_WarnEx(
5191-
PyExc_DeprecationWarning,
5190+
if (PyErr_WarnEx(PyExc_DeprecationWarning,
51925191
"datetime.utcfromtimestamp() is deprecated and scheduled for removal "
51935192
"in a future version. Use timezone-aware objects to represent "
5194-
"datetimes in UTC: datetime.now(datetime.UTC).",
5195-
2
5196-
);
5193+
"datetimes in UTC: datetime.now(datetime.UTC).", 2))
5194+
{
5195+
return NULL;
5196+
}
51975197
PyObject *timestamp;
51985198
PyObject *result = NULL;
51995199

Python/specialize.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ specialize_module_load_attr(
515515
/* Attribute specialization */
516516

517517
void
518-
_Py_Specialize_LoadSuperAttr(PyObject *global_super, PyObject *class, PyObject *self,
518+
_Py_Specialize_LoadSuperAttr(PyObject *global_super, PyObject *cls, PyObject *self,
519519
_Py_CODEUNIT *instr, PyObject *name, int load_method) {
520520
assert(ENABLE_SPECIALIZATION);
521521
assert(_PyOpcode_Caches[LOAD_SUPER_ATTR] == INLINE_CACHE_ENTRIES_LOAD_SUPER_ATTR);
@@ -528,11 +528,11 @@ _Py_Specialize_LoadSuperAttr(PyObject *global_super, PyObject *class, PyObject *
528528
SPECIALIZATION_FAIL(LOAD_SUPER_ATTR, SPEC_FAIL_SUPER_SHADOWED);
529529
goto fail;
530530
}
531-
if (!PyType_Check(class)) {
531+
if (!PyType_Check(cls)) {
532532
SPECIALIZATION_FAIL(LOAD_SUPER_ATTR, SPEC_FAIL_SUPER_BAD_CLASS);
533533
goto fail;
534534
}
535-
PyTypeObject *tp = (PyTypeObject *)class;
535+
PyTypeObject *tp = (PyTypeObject *)cls;
536536
PyObject *res = _PySuper_LookupDescr(tp, self, name);
537537
if (res == NULL) {
538538
SPECIALIZATION_FAIL(LOAD_SUPER_ATTR, SPEC_FAIL_SUPER_ERROR_OR_NOT_FOUND);

0 commit comments

Comments
 (0)