Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-132775: Use _PyCode GetScriptXIData()#134511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
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
2 changes: 1 addition & 1 deletionLib/test/support/interpreters/channels.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -69,7 +69,7 @@ def list_all():
ifnothasattr(send,'_unboundop'):
send._set_unbound(unboundop)
else:
assertsend._unbound[0]==op
assertsend._unbound[0]==unboundop
channels.append(chan)
returnchannels

Expand Down
25 changes: 16 additions & 9 deletionsLib/test/test__interpreters.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -474,13 +474,15 @@ def setUp(self):

deftest_signatures(self):
# See https://github.com/python/cpython/issues/126654
msg="expected 'shared' to be adict"
msg=r'_interpreters.exec\(\) argument 3 must bedict, not int'
withself.assertRaisesRegex(TypeError,msg):
_interpreters.exec(self.id,'a',1)
withself.assertRaisesRegex(TypeError,msg):
_interpreters.exec(self.id,'a',shared=1)
msg=r'_interpreters.run_string\(\) argument 3 must be dict, not int'
withself.assertRaisesRegex(TypeError,msg):
_interpreters.run_string(self.id,'a',shared=1)
msg=r'_interpreters.run_func\(\) argument 3 must be dict, not int'
withself.assertRaisesRegex(TypeError,msg):
_interpreters.run_func(self.id,lambda:None,shared=1)

Expand DownExpand Up@@ -952,7 +954,8 @@ def test_invalid_syntax(self):
""")

withself.subTest('script'):
self.assert_run_failed(SyntaxError,script)
withself.assertRaises(SyntaxError):
_interpreters.run_string(self.id,script)

withself.subTest('module'):
modname='spam_spam_spam'
Expand DownExpand Up@@ -1019,12 +1022,19 @@ def script():
withopen(w,'w',encoding="utf-8")asspipe:
withcontextlib.redirect_stdout(spipe):
print('it worked!',end='')
failed=None
deff():
_interpreters.set___main___attrs(self.id,dict(w=w))
_interpreters.run_func(self.id,script)
nonlocalfailed
try:
_interpreters.set___main___attrs(self.id,dict(w=w))
_interpreters.run_func(self.id,script)
exceptExceptionasexc:
failed=exc
t=threading.Thread(target=f)
t.start()
t.join()
iffailed:
raiseExceptionfromfailed

withopen(r,encoding="utf-8")asoutfile:
out=outfile.read()
Expand DownExpand Up@@ -1053,19 +1063,16 @@ def test_closure(self):
spam=True
defscript():
assertspam

withself.assertRaises(TypeError):
withself.assertRaises(ValueError):
_interpreters.run_func(self.id,script)

# XXX This hasn't been fixed yet.
@unittest.expectedFailure
deftest_return_value(self):
defscript():
return'spam'
withself.assertRaises(ValueError):
_interpreters.run_func(self.id,script)

@unittest.skip("we're not quite there yet")
# @unittest.skip("we're not quite there yet")
deftest_args(self):
withself.subTest('args'):
defscript(a,b=0):
Expand Down
23 changes: 15 additions & 8 deletionsLib/test/test_interpreters/test_api.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -839,9 +839,16 @@ def test_bad_script(self):
interp.exec(10)

deftest_bytes_for_script(self):
r,w=self.pipe()
RAN=b'R'
DONE=b'D'
interp=interpreters.create()
withself.assertRaises(TypeError):
interp.exec(b'print("spam")')
interp.exec(f"""if True:
import os
os.write({w},{RAN!r})
""")
os.write(w,DONE)
self.assertEqual(os.read(r,1),RAN)

deftest_with_background_threads_still_running(self):
r_interp,w_interp=self.pipe()
Expand DownExpand Up@@ -1010,8 +1017,6 @@ def test_call(self):

fori, (callable,args,kwargs)inenumerate([
(call_func_noop, (), {}),
(call_func_return_shareable, (), {}),
(call_func_return_not_shareable, (), {}),
(Spam.noop, (), {}),
]):
withself.subTest(f'success case #{i+1}'):
Expand All@@ -1036,6 +1041,8 @@ def test_call(self):
(call_func_complex, ('custom','spam!'), {}),
(call_func_complex, ('custom-inner','eggs!'), {}),
(call_func_complex, ('???',), {'exc':ValueError('spam')}),
(call_func_return_shareable, (), {}),
(call_func_return_not_shareable, (), {}),
]):
withself.subTest(f'invalid case #{i+1}'):
withself.assertRaises(Exception):
Expand All@@ -1051,8 +1058,6 @@ def test_call_in_thread(self):

fori, (callable,args,kwargs)inenumerate([
(call_func_noop, (), {}),
(call_func_return_shareable, (), {}),
(call_func_return_not_shareable, (), {}),
(Spam.noop, (), {}),
]):
withself.subTest(f'success case #{i+1}'):
Expand All@@ -1079,6 +1084,8 @@ def test_call_in_thread(self):
(call_func_complex, ('custom','spam!'), {}),
(call_func_complex, ('custom-inner','eggs!'), {}),
(call_func_complex, ('???',), {'exc':ValueError('spam')}),
(call_func_return_shareable, (), {}),
(call_func_return_not_shareable, (), {}),
]):
withself.subTest(f'invalid case #{i+1}'):
ifargsorkwargs:
Expand DownExpand Up@@ -1618,8 +1625,8 @@ def test_exec(self):
deftest_call(self):
withself.subTest('no args'):
interpid=_interpreters.create()
exc=_interpreters.call(interpid,call_func_return_shareable)
self.assertIs(exc,None)
withself.assertRaises(ValueError):
_interpreters.call(interpid,call_func_return_shareable)

withself.subTest('uncaught exception'):
interpid=_interpreters.create()
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp