Skip to content

Commit 286e3c7

Browse files
authored
gh-99087: Add missing newline for prompts in docs (GH-98993)
Add newline for prompts so copying to REPL does not cause errors.
1 parent 3e06b50 commit 286e3c7

22 files changed

+43
-0
lines changed

Doc/howto/enum.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ And a function to display the chores for a given day::
158158
... for chore, days in chores.items():
159159
... if day in days:
160160
... print(chore)
161+
...
161162
>>> show_chores(chores_for_ethan, Weekday.SATURDAY)
162163
answer SO questions
163164

@@ -712,6 +713,7 @@ It is also possible to name the combinations::
712713
... W = 2
713714
... X = 1
714715
... RWX = 7
716+
...
715717
>>> Perm.RWX
716718
<Perm.RWX: 7>
717719
>>> ~Perm.RWX

Doc/library/argparse.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ arguments they contain. For example::
565565

566566
>>> with open('args.txt', 'w', encoding=sys.getfilesystemencoding()) as fp:
567567
... fp.write('-f\nbar')
568+
...
568569
>>> parser = argparse.ArgumentParser(fromfile_prefix_chars='@')
569570
>>> parser.add_argument('-f')
570571
>>> parser.parse_args(['-f', 'foo', '@args.txt'])

Doc/library/bz2.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,11 @@ Writing and reading a bzip2-compressed file in binary mode:
320320
>>> with bz2.open("myfile.bz2", "wb") as f:
321321
... # Write compressed data to file
322322
... unused = f.write(data)
323+
...
323324
>>> with bz2.open("myfile.bz2", "rb") as f:
324325
... # Decompress data from file
325326
... content = f.read()
327+
...
326328
>>> content == data # Check equality to original object after round-trip
327329
True
328330

Doc/library/collections.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ For example::
229229
>>> cnt = Counter()
230230
>>> for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']:
231231
... cnt[word] += 1
232+
...
232233
>>> cnt
233234
Counter({'blue': 3, 'red': 2, 'green': 1})
234235

@@ -818,6 +819,7 @@ zero):
818819

819820
>>> def constant_factory(value):
820821
... return lambda: value
822+
...
821823
>>> d = defaultdict(constant_factory('<missing>'))
822824
>>> d.update(name='John', action='ran')
823825
>>> '%(name)s %(action)s to %(object)s' % d

Doc/library/datetime.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,7 @@ Example of counting days to an event::
765765
>>> my_birthday = date(today.year, 6, 24)
766766
>>> if my_birthday < today:
767767
... my_birthday = my_birthday.replace(year=today.year + 1)
768+
...
768769
>>> my_birthday
769770
datetime.date(2008, 6, 24)
770771
>>> time_to_birthday = abs(my_birthday - today)

Doc/library/decimal.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,6 +2057,7 @@ to handle the :meth:`quantize` step:
20572057

20582058
>>> def mul(x, y, fp=TWOPLACES):
20592059
... return (x * y).quantize(fp)
2060+
...
20602061
>>> def div(x, y, fp=TWOPLACES):
20612062
... return (x / y).quantize(fp)
20622063

Doc/library/doctest.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ The fine print:
351351

352352
>>> def f(x):
353353
... r'''Backslashes in a raw docstring: m\n'''
354+
...
354355
>>> print(f.__doc__)
355356
Backslashes in a raw docstring: m\n
356357

@@ -360,6 +361,7 @@ The fine print:
360361

361362
>>> def f(x):
362363
... '''Backslashes in a raw docstring: m\\n'''
364+
...
363365
>>> print(f.__doc__)
364366
Backslashes in a raw docstring: m\n
365367

Doc/library/email.policy.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ file on disk and pass it to the system ``sendmail`` program on a Unix system:
9797
>>> from subprocess import Popen, PIPE
9898
>>> with open('mymsg.txt', 'rb') as f:
9999
... msg = message_from_binary_file(f, policy=policy.default)
100+
...
100101
>>> p = Popen(['sendmail', msg['To'].addresses[0]], stdin=PIPE)
101102
>>> g = BytesGenerator(p.stdin, policy=msg.policy.clone(linesep='\r\n'))
102103
>>> g.flatten(msg)

Doc/library/enum.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ Data Types
292292
... @classmethod
293293
... def today(cls):
294294
... print('today is %s' % cls(date.today().isoweekday()).name)
295+
...
295296
>>> dir(Weekday.SATURDAY)
296297
['__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', 'today', 'value']
297298

@@ -312,6 +313,7 @@ Data Types
312313
... return (count + 1) * 3
313314
... FIRST = auto()
314315
... SECOND = auto()
316+
...
315317
>>> PowersOfThree.SECOND.value
316318
6
317319

@@ -336,6 +338,7 @@ Data Types
336338
... if member.value == value:
337339
... return member
338340
... return None
341+
...
339342
>>> Build.DEBUG.value
340343
'debug'
341344
>>> Build('deBUG')
@@ -353,6 +356,7 @@ Data Types
353356
... def __repr__(self):
354357
... cls_name = self.__class__.__name__
355358
... return f'{cls_name}.{self.name}'
359+
...
356360
>>> OtherStyle.ALTERNATE, str(OtherStyle.ALTERNATE), f"{OtherStyle.ALTERNATE}"
357361
(OtherStyle.ALTERNATE, 'OtherStyle.ALTERNATE', 'OtherStyle.ALTERNATE')
358362

@@ -367,6 +371,7 @@ Data Types
367371
... SOMETHING_ELSE = auto()
368372
... def __str__(self):
369373
... return f'{self.name}'
374+
...
370375
>>> OtherStyle.ALTERNATE, str(OtherStyle.ALTERNATE), f"{OtherStyle.ALTERNATE}"
371376
(<OtherStyle.ALTERNATE: 1>, 'ALTERNATE', 'ALTERNATE')
372377

@@ -381,6 +386,7 @@ Data Types
381386
... SOMETHING_ELSE = auto()
382387
... def __format__(self, spec):
383388
... return f'{self.name}'
389+
...
384390
>>> OtherStyle.ALTERNATE, str(OtherStyle.ALTERNATE), f"{OtherStyle.ALTERNATE}"
385391
(<OtherStyle.ALTERNATE: 1>, 'OtherStyle.ALTERNATE', 'ALTERNATE')
386392

@@ -403,6 +409,7 @@ Data Types
403409
... ONE = 1
404410
... TWO = 2
405411
... THREE = 3
412+
...
406413
>>> Numbers.THREE
407414
<Numbers.THREE: 3>
408415
>>> Numbers.ONE + Numbers.TWO
@@ -463,6 +470,7 @@ Data Types
463470
... RED = auto()
464471
... GREEN = auto()
465472
... BLUE = auto()
473+
...
466474
>>> purple = Color.RED | Color.BLUE
467475
>>> white = Color.RED | Color.GREEN | Color.BLUE
468476
>>> Color.GREEN in purple
@@ -570,6 +578,7 @@ Data Types
570578
... RED = auto()
571579
... GREEN = auto()
572580
... BLUE = auto()
581+
...
573582
>>> Color.RED & 2
574583
<Color: 0>
575584
>>> Color.RED | 2
@@ -695,6 +704,7 @@ Data Types
695704
... RED = auto()
696705
... GREEN = auto()
697706
... BLUE = auto()
707+
...
698708
>>> StrictFlag(2**2 + 2**4)
699709
Traceback (most recent call last):
700710
...
@@ -712,6 +722,7 @@ Data Types
712722
... RED = auto()
713723
... GREEN = auto()
714724
... BLUE = auto()
725+
...
715726
>>> ConformFlag(2**2 + 2**4)
716727
<ConformFlag.BLUE: 4>
717728

@@ -725,6 +736,7 @@ Data Types
725736
... RED = auto()
726737
... GREEN = auto()
727738
... BLUE = auto()
739+
...
728740
>>> EjectFlag(2**2 + 2**4)
729741
20
730742

@@ -738,6 +750,7 @@ Data Types
738750
... RED = auto()
739751
... GREEN = auto()
740752
... BLUE = auto()
753+
...
741754
>>> KeepFlag(2**2 + 2**4)
742755
<KeepFlag.BLUE|16: 20>
743756

Doc/library/functions.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ are always available. They are listed here in alphabetical order.
462462
>>> class Shape:
463463
... def __dir__(self):
464464
... return ['area', 'perimeter', 'location']
465+
...
465466
>>> s = Shape()
466467
>>> dir(s)
467468
['area', 'location', 'perimeter']

0 commit comments

Comments
 (0)