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

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More changes.
  • Loading branch information
serhiy-storchaka committed Aug 30, 2019
commit d7dda9077aa4970e431f98a563bb5ced8a32c0b2
8 changes: 4 additions & 4 deletions Lib/_pyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -2295,7 +2295,7 @@ def _read_chunk(self):
return not eof

def _pack_cookie(self, position, dec_flags=0,
bytes_to_feed=0, need_eof=0, chars_to_skip=0):
bytes_to_feed=0, need_eof=False, chars_to_skip=0):
# The meaning of a tell() cookie is: seek to position, set the
# decoder flags to dec_flags, read bytes_to_feed bytes, feed them
# into the decoder with need_eof as the EOF flag, then skip
Expand All @@ -2309,7 +2309,7 @@ def _unpack_cookie(self, bigint):
rest, dec_flags = divmod(rest, 1<<64)
rest, bytes_to_feed = divmod(rest, 1<<64)
need_eof, chars_to_skip = divmod(rest, 1<<64)
return position, dec_flags, bytes_to_feed, need_eof, chars_to_skip
return position, dec_flags, bytes_to_feed, bool(need_eof), chars_to_skip

def tell(self):
if not self._seekable:
Expand Down Expand Up @@ -2383,7 +2383,7 @@ def tell(self):
# (a point where the decoder has nothing buffered, so seek()
# can safely start from there and advance to this location).
bytes_fed = 0
need_eof = 0
need_eof = False
# Chars decoded since `start_pos`
chars_decoded = 0
for i in range(skip_bytes, len(next_input)):
Expand All @@ -2400,7 +2400,7 @@ def tell(self):
else:
# We didn't get enough decoded data; signal EOF to get more.
chars_decoded += len(decoder.decode(b'', final=True))
need_eof = 1
need_eof = True
if chars_decoded < chars_to_skip:
raise OSError("can't reconstruct logical file position")

Expand Down
4 changes: 2 additions & 2 deletions Lib/asyncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def __init__(self, sock=None, map=None):
if sock:
# Set to nonblocking just to make sure for cases where we
# get a socket from a blocking source.
sock.setblocking(0)
sock.setblocking(False)
self.set_socket(sock, map)
self.connected = True
# The constructor no longer requires that the socket
Expand Down Expand Up @@ -280,7 +280,7 @@ def del_channel(self, map=None):
def create_socket(self, family=socket.AF_INET, type=socket.SOCK_STREAM):
self.family_and_type = family, type
sock = socket.socket(family, type)
sock.setblocking(0)
sock.setblocking(False)
self.set_socket(sock)

def set_socket(self, sock, map=None):
Expand Down
2 changes: 1 addition & 1 deletion Lib/codeop.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def __init__(self):
self.flags = PyCF_DONT_IMPLY_DEDENT

def __call__(self, source, filename, symbol):
codeob = compile(source, filename, symbol, self.flags, 1)
codeob = compile(source, filename, symbol, self.flags, True)
Copy link
Contributor

@sir-sigurd sir-sigurd Aug 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that's OK.

https://docs.python.org/3.9/library/functions.html#compile

The argument optimize specifies the optimization level of the compiler; the default value of -1 selects the optimization level of the interpreter as given by -O options. Explicit levels are 0 (no optimization; debug is true), 1 (asserts are removed, debug is false) or 2 (docstrings are removed too).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is dont_inherit, not optimize.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, sorry.

for feature in _features:
if codeob.co_flags & feature.compiler_flag:
self.flags |= feature.compiler_flag
Expand Down
2 changes: 1 addition & 1 deletion Lib/doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ def __run(self, test, compileflags, out):
try:
# Don't blink! This is where the user's code gets run.
exec(compile(example.source, filename, "single",
compileflags, 1), test.globs)
compileflags, True), test.globs)
self.debugger.set_continue() # ==== Example Finished ====
exception = None
except KeyboardInterrupt:
Expand Down
8 changes: 4 additions & 4 deletions Lib/quopri.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,11 @@ def main():
print("-t: quote tabs")
print("-d: decode; default encode")
sys.exit(2)
deco = 0
tabs = 0
deco = False
tabs = False
for o, a in opts:
if o == '-t': tabs = 1
if o == '-d': deco = 1
if o == '-t': tabs = True
if o == '-d': deco = True
if tabs and deco:
sys.stdout = sys.stderr
print("-t and -d are mutually exclusive")
Expand Down
16 changes: 8 additions & 8 deletions Lib/test/datetimetester.py
Original file line number Diff line number Diff line change
Expand Up @@ -6160,7 +6160,7 @@ class TZInfoSubclass(tzinfo):
def test_date_from_date(self):
exp_date = date(1993, 8, 26)

for macro in [0, 1]:
for macro in False, True:
with self.subTest(macro=macro):
c_api_date = _testcapi.get_date_fromdate(
macro,
Expand All @@ -6173,7 +6173,7 @@ def test_date_from_date(self):
def test_datetime_from_dateandtime(self):
exp_date = datetime(1993, 8, 26, 22, 12, 55, 99999)

for macro in [0, 1]:
for macro in False, True:
with self.subTest(macro=macro):
c_api_date = _testcapi.get_datetime_fromdateandtime(
macro,
Expand All @@ -6191,7 +6191,7 @@ def test_datetime_from_dateandtimeandfold(self):
exp_date = datetime(1993, 8, 26, 22, 12, 55, 99999)

for fold in [0, 1]:
for macro in [0, 1]:
for macro in False, True:
with self.subTest(macro=macro, fold=fold):
c_api_date = _testcapi.get_datetime_fromdateandtimeandfold(
macro,
Expand All @@ -6210,7 +6210,7 @@ def test_datetime_from_dateandtimeandfold(self):
def test_time_from_time(self):
exp_time = time(22, 12, 55, 99999)

for macro in [0, 1]:
for macro in False, True:
with self.subTest(macro=macro):
c_api_time = _testcapi.get_time_fromtime(
macro,
Expand All @@ -6225,7 +6225,7 @@ def test_time_from_timeandfold(self):
exp_time = time(22, 12, 55, 99999)

for fold in [0, 1]:
for macro in [0, 1]:
for macro in False, True:
with self.subTest(macro=macro, fold=fold):
c_api_time = _testcapi.get_time_fromtimeandfold(
macro,
Expand All @@ -6241,7 +6241,7 @@ def test_time_from_timeandfold(self):
def test_delta_from_dsu(self):
exp_delta = timedelta(26, 55, 99999)

for macro in [0, 1]:
for macro in False, True:
with self.subTest(macro=macro):
c_api_delta = _testcapi.get_delta_fromdsu(
macro,
Expand All @@ -6254,7 +6254,7 @@ def test_delta_from_dsu(self):
def test_date_from_timestamp(self):
ts = datetime(1995, 4, 12).timestamp()

for macro in [0, 1]:
for macro in False, True:
with self.subTest(macro=macro):
d = _testcapi.get_date_fromtimestamp(int(ts), macro)

Expand All @@ -6272,7 +6272,7 @@ def test_datetime_from_timestamp(self):

from_timestamp = _testcapi.get_datetime_fromtimestamp
for case in cases:
for macro in [0, 1]:
for macro in False, True:
with self.subTest(case=case, macro=macro):
dtup, tzinfo, usetz = case
dt_orig = datetime(*dtup, tzinfo=tzinfo)
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/lock_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def f():
def test_timeout(self):
lock = self.locktype()
# Can't set timeout if not blocking
self.assertRaises(ValueError, lock.acquire, 0, 1)
self.assertRaises(ValueError, lock.acquire, False, 1)
# Invalid timeout values
self.assertRaises(ValueError, lock.acquire, timeout=-100)
self.assertRaises(OverflowError, lock.acquire, timeout=1e100)
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_asyncio/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def stop(self):
def run(self):
try:
with self._sock:
self._sock.setblocking(0)
self._sock.setblocking(False)
self._run()
finally:
self._s1.close()
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ def test_compile(self):
bom = b'\xef\xbb\xbf'
compile(bom + b'print(1)\n', '', 'exec')
compile(source='pass', filename='?', mode='exec')
compile(dont_inherit=0, filename='tmp', source='0', mode='eval')
compile('pass', '?', dont_inherit=1, mode='exec')
compile(dont_inherit=False, filename='tmp', source='0', mode='eval')
compile('pass', '?', dont_inherit=True, mode='exec')
compile(memoryview(b"text"), "name", "exec")
self.assertRaises(TypeError, compile)
self.assertRaises(ValueError, compile, 'print(42)\n', '<string>', 'badmode')
Expand Down Expand Up @@ -1853,7 +1853,7 @@ def test_basic(self):
self.assertEqual(data, sorted(copy, key=lambda x: -x))
self.assertNotEqual(data, copy)
random.shuffle(copy)
self.assertEqual(data, sorted(copy, reverse=1))
self.assertEqual(data, sorted(copy, reverse=True))
self.assertNotEqual(data, copy)

def test_bad_arguments(self):
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_ioctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _check_ioctl_mutate_len(self, nbytes=None):
else:
buf.append(fill)
with open("/dev/tty", "rb") as tty:
r = fcntl.ioctl(tty, termios.TIOCGPGRP, buf, 1)
r = fcntl.ioctl(tty, termios.TIOCGPGRP, buf, True)
rpgrp = buf[0]
self.assertEqual(r, 0)
self.assertIn(rpgrp, ids)
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_ordered_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,9 @@ def test_move_to_end(self):
self.assertEqual(list(od), list('abcde'))
od.move_to_end('c')
self.assertEqual(list(od), list('abdec'))
od.move_to_end('c', 0)
od.move_to_end('c', False)
self.assertEqual(list(od), list('cabde'))
od.move_to_end('c', 0)
od.move_to_end('c', False)
self.assertEqual(list(od), list('cabde'))
od.move_to_end('e')
self.assertEqual(list(od), list('cabde'))
Expand All @@ -418,7 +418,7 @@ def test_move_to_end(self):
with self.assertRaises(KeyError):
od.move_to_end('x')
with self.assertRaises(KeyError):
od.move_to_end('x', 0)
od.move_to_end('x', False)

def test_move_to_end_issue25406(self):
OrderedDict = self.OrderedDict
Expand Down
Loading