Skip to content

Commit 8000e9b

Browse files
committed
Merge branch 'main' of https://github.com/python/cpython into pep-788-impl
2 parents a1a332e + e3d9bd6 commit 8000e9b

6 files changed

Lines changed: 49 additions & 21 deletions

File tree

Lib/_strptime.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -627,18 +627,18 @@ def parse_int(s):
627627
hour = parse_int(found_dict['I'])
628628
ampm = found_dict.get('p', '').lower()
629629
# If there was no AM/PM indicator, we'll treat this like AM
630-
if ampm in ('', locale_time.am_pm[0]):
631-
# We're in AM so the hour is correct unless we're
632-
# looking at 12 midnight.
633-
# 12 midnight == 12 AM == hour 0
634-
if hour == 12:
635-
hour = 0
636-
elif ampm == locale_time.am_pm[1]:
630+
if ampm == locale_time.am_pm[1]:
637631
# We're in PM so we need to add 12 to the hour unless
638632
# we're looking at 12 noon.
639633
# 12 noon == 12 PM == hour 12
640634
if hour != 12:
641635
hour += 12
636+
else:
637+
# We're in AM so the hour is correct unless we're
638+
# looking at 12 midnight.
639+
# 12 midnight == 12 AM == hour 0
640+
if hour == 12:
641+
hour = 0
642642
elif group_key == 'M':
643643
minute = parse_int(found_dict['M'])
644644
elif group_key == 'S':

Lib/test/datetimetester.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2942,6 +2942,16 @@ def test_strptime(self):
29422942
with self.assertRaises(ValueError): strptime("-000", "%z")
29432943
with self.assertRaises(ValueError): strptime("z", "%z")
29442944

2945+
def test_strptime_ampm(self):
2946+
dt = datetime(1999, 3, 17, 0, 44, 55, 2)
2947+
for hour in range(0, 24):
2948+
with self.subTest(hour=hour):
2949+
new_dt = dt.replace(hour=hour)
2950+
dt_str = new_dt.strftime("%I %p")
2951+
2952+
self.assertEqual(self.theclass.strptime(dt_str, "%I %p").hour,
2953+
hour)
2954+
29452955
def test_strptime_single_digit(self):
29462956
# bpo-34903: Check that single digit dates and times are allowed.
29472957

Makefile.pre.in

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3126,11 +3126,27 @@ JIT_DEPS = \
31263126
$(srcdir)/Tools/jit/*.py \
31273127
$(srcdir)/Python/executor_cases.c.h \
31283128
pyconfig.h
3129-
3130-
jit_stencils.h: $(JIT_DEPS)
3129+
3130+
ifneq ($(filter aarch64-apple-darwin%,$(HOST_GNU_TYPE)),)
3131+
JIT_STENCIL_HEADER := jit_stencils-aarch64-apple-darwin.h
3132+
else ifneq ($(filter x86_64-apple-darwin%,$(HOST_GNU_TYPE)),)
3133+
JIT_STENCIL_HEADER := jit_stencils-x86_64-apple-darwin.h
3134+
else ifeq ($(HOST_GNU_TYPE), aarch64-pc-windows-msvc)
3135+
JIT_STENCIL_HEADER := jit_stencils-aarch64-pc-windows-msvc.h
3136+
else ifeq ($(HOST_GNU_TYPE), i686-pc-windows-msvc)
3137+
JIT_STENCIL_HEADER := jit_stencils-i686-pc-windows-msvc.h
3138+
else ifeq ($(HOST_GNU_TYPE), x86_64-pc-windows-msvc)
3139+
JIT_STENCIL_HEADER := jit_stencils-x86_64-pc-windows-msvc.h
3140+
else ifneq ($(filter aarch64-%-linux-gnu,$(HOST_GNU_TYPE)),)
3141+
JIT_STENCIL_HEADER := jit_stencils-$(HOST_GNU_TYPE).h
3142+
else ifneq ($(filter x86_64-%-linux-gnu,$(HOST_GNU_TYPE)),)
3143+
JIT_STENCIL_HEADER := jit_stencils-$(HOST_GNU_TYPE).h
3144+
endif
3145+
3146+
jit_stencils.h $(JIT_STENCIL_HEADER): $(JIT_DEPS)
31313147
@REGEN_JIT_COMMAND@
31323148

3133-
Python/jit.o: $(srcdir)/Python/jit.c @JIT_STENCILS_H@
3149+
Python/jit.o: $(srcdir)/Python/jit.c jit_stencils.h $(JIT_STENCIL_HEADER)
31343150
$(CC) -c $(PY_CORE_CFLAGS) -o $@ $<
31353151

31363152
.PHONY: regen-jit
@@ -3228,7 +3244,7 @@ clean-retain-profile: pycremoval
32283244
-rm -rf Python/deepfreeze
32293245
-rm -f Python/frozen_modules/*.h
32303246
-rm -f Python/frozen_modules/MANIFEST
3231-
-rm -f jit_stencils.h
3247+
-rm -f jit_stencils*.h
32323248
-find build -type f -a ! -name '*.gc??' -exec rm -f {} ';'
32333249
-rm -f Include/pydtrace_probes.h
32343250
-rm -f profile-gen-stamp

Tools/jit/_targets.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -551,38 +551,45 @@ def get_target(host: str) -> _COFF32 | _COFF64 | _ELF | _MachO:
551551
optimizer: type[_optimizers.Optimizer]
552552
target: _COFF32 | _COFF64 | _ELF | _MachO
553553
if re.fullmatch(r"aarch64-apple-darwin.*", host):
554+
host = "aarch64-apple-darwin"
554555
condition = "defined(__aarch64__) && defined(__APPLE__)"
555556
optimizer = _optimizers.OptimizerAArch64
556557
target = _MachO(host, condition, optimizer=optimizer)
557558
elif re.fullmatch(r"aarch64-pc-windows-msvc", host):
558-
args = ["-fms-runtime-lib=dll", "-fplt"]
559+
host = "aarch64-pc-windows-msvc"
559560
condition = "defined(_M_ARM64)"
561+
args = ["-fms-runtime-lib=dll", "-fplt"]
560562
optimizer = _optimizers.OptimizerAArch64
561563
target = _COFF64(host, condition, args=args, optimizer=optimizer)
562564
elif re.fullmatch(r"aarch64-.*-linux-gnu", host):
565+
host = "aarch64-unknown-linux-gnu"
566+
condition = "defined(__aarch64__) && defined(__linux__)"
563567
# -mno-outline-atomics: Keep intrinsics from being emitted.
564568
args = ["-fpic", "-mno-outline-atomics"]
565-
condition = "defined(__aarch64__) && defined(__linux__)"
566569
optimizer = _optimizers.OptimizerAArch64
567570
target = _ELF(host, condition, args=args, optimizer=optimizer)
568571
elif re.fullmatch(r"i686-pc-windows-msvc", host):
572+
host = "i686-pc-windows-msvc"
573+
condition = "defined(_M_IX86)"
569574
# -Wno-ignored-attributes: __attribute__((preserve_none)) is not supported here.
570575
args = ["-DPy_NO_ENABLE_SHARED", "-Wno-ignored-attributes"]
571576
optimizer = _optimizers.OptimizerX86
572-
condition = "defined(_M_IX86)"
573577
target = _COFF32(host, condition, args=args, optimizer=optimizer)
574578
elif re.fullmatch(r"x86_64-apple-darwin.*", host):
579+
host = "x86_64-apple-darwin"
575580
condition = "defined(__x86_64__) && defined(__APPLE__)"
576581
optimizer = _optimizers.OptimizerX86
577582
target = _MachO(host, condition, optimizer=optimizer)
578583
elif re.fullmatch(r"x86_64-pc-windows-msvc", host):
579-
args = ["-fms-runtime-lib=dll"]
584+
host = "x86_64-pc-windows-msvc"
580585
condition = "defined(_M_X64)"
586+
args = ["-fms-runtime-lib=dll"]
581587
optimizer = _optimizers.OptimizerX86
582588
target = _COFF64(host, condition, args=args, optimizer=optimizer)
583589
elif re.fullmatch(r"x86_64-.*-linux-gnu", host):
584-
args = ["-fno-pic", "-mcmodel=medium", "-mlarge-data-threshold=0"]
590+
host = "x86_64-unknown-linux-gnu"
585591
condition = "defined(__x86_64__) && defined(__linux__)"
592+
args = ["-fno-pic", "-mcmodel=medium", "-mlarge-data-threshold=0"]
586593
optimizer = _optimizers.OptimizerX86
587594
target = _ELF(host, condition, args=args, optimizer=optimizer)
588595
else:

configure

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2787,13 +2787,11 @@ AS_VAR_IF([jit_flags],
27872787
[AS_VAR_APPEND([CFLAGS_NODIST], [" $jit_flags"])
27882788
AS_VAR_SET([REGEN_JIT_COMMAND],
27892789
["\$(PYTHON_FOR_REGEN) \$(srcdir)/Tools/jit/build.py ${ARCH_TRIPLES:-$host} --output-dir . --pyconfig-dir . --cflags=\"$CFLAGS_JIT\""])
2790-
AS_VAR_SET([JIT_STENCILS_H], ["jit_stencils.h"])
27912790
AS_VAR_IF([Py_DEBUG],
27922791
[true],
27932792
[AS_VAR_APPEND([REGEN_JIT_COMMAND], [" --debug"])],
27942793
[])])
27952794
AC_SUBST([REGEN_JIT_COMMAND])
2796-
AC_SUBST([JIT_STENCILS_H])
27972795
AC_MSG_RESULT([$tier2_flags $jit_flags])
27982796

27992797
if test "$disable_gil" = "yes" -a "$enable_experimental_jit" != "no"; then

0 commit comments

Comments
 (0)