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

Commit867bd10

Browse files
committed
Merge branch 'main' into virtual-iterators
2 parents5cd55c4 +ac06b53 commit867bd10

17 files changed

+800
-430
lines changed

‎Include/internal/pycore_crossinterp.h

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -335,71 +335,29 @@ typedef struct _sharedexception {
335335
PyAPI_FUNC(PyObject*)_PyXI_ApplyError(_PyXI_error*err);
336336

337337

338-
typedefstructxi_session_PyXI_session;
339-
typedefstruct_sharedns_PyXI_namespace;
340-
341-
PyAPI_FUNC(void)_PyXI_FreeNamespace(_PyXI_namespace*ns);
342-
PyAPI_FUNC(_PyXI_namespace*)_PyXI_NamespaceFromNames(PyObject*names);
343-
PyAPI_FUNC(int)_PyXI_FillNamespaceFromDict(
344-
_PyXI_namespace*ns,
345-
PyObject*nsobj,
346-
_PyXI_session*session);
347-
PyAPI_FUNC(int)_PyXI_ApplyNamespace(
348-
_PyXI_namespace*ns,
349-
PyObject*nsobj,
350-
PyObject*dflt);
351-
352-
353338
// A cross-interpreter session involves entering an interpreter
354-
//(_PyXI_Enter()), doing some work with it, and finally exiting
355-
// that interpreter(_PyXI_Exit()).
339+
//with_PyXI_Enter(), doing some work with it, and finally exiting
340+
// that interpreterwith_PyXI_Exit().
356341
//
357342
// At the boundaries of the session, both entering and exiting,
358343
// data may be exchanged between the previous interpreter and the
359344
// target one in a thread-safe way that does not violate the
360345
// isolation between interpreters. This includes setting objects
361346
// in the target's __main__ module on the way in, and capturing
362347
// uncaught exceptions on the way out.
363-
structxi_session {
364-
// Once a session has been entered, this is the tstate that was
365-
// current before the session. If it is different from cur_tstate
366-
// then we must have switched interpreters. Either way, this will
367-
// be the current tstate once we exit the session.
368-
PyThreadState*prev_tstate;
369-
// Once a session has been entered, this is the current tstate.
370-
// It must be current when the session exits.
371-
PyThreadState*init_tstate;
372-
// This is true if init_tstate needs cleanup during exit.
373-
intown_init_tstate;
374-
375-
// This is true if, while entering the session, init_thread took
376-
// "ownership" of the interpreter's __main__ module. This means
377-
// it is the only thread that is allowed to run code there.
378-
// (Caveat: for now, users may still run exec() against the
379-
// __main__ module's dict, though that isn't advisable.)
380-
intrunning;
381-
// This is a cached reference to the __dict__ of the entered
382-
// interpreter's __main__ module. It is looked up when at the
383-
// beginning of the session as a convenience.
384-
PyObject*main_ns;
385-
386-
// This is set if the interpreter is entered and raised an exception
387-
// that needs to be handled in some special way during exit.
388-
_PyXI_errcode*error_override;
389-
// This is set if exit captured an exception to propagate.
390-
_PyXI_error*error;
391-
392-
// -- pre-allocated memory --
393-
_PyXI_error_error;
394-
_PyXI_errcode_error_override;
395-
};
348+
typedefstructxi_session_PyXI_session;
349+
350+
PyAPI_FUNC(_PyXI_session*)_PyXI_NewSession(void);
351+
PyAPI_FUNC(void)_PyXI_FreeSession(_PyXI_session*);
396352

397353
PyAPI_FUNC(int)_PyXI_Enter(
398354
_PyXI_session*session,
399355
PyInterpreterState*interp,
400356
PyObject*nsupdates);
401357
PyAPI_FUNC(void)_PyXI_Exit(_PyXI_session*session);
402358

359+
PyAPI_FUNC(PyObject*)_PyXI_GetMainNamespace(_PyXI_session*);
360+
403361
PyAPI_FUNC(PyObject*)_PyXI_ApplyCapturedException(_PyXI_session*session);
404362
PyAPI_FUNC(int)_PyXI_HasCapturedException(_PyXI_session*session);
405363

‎Include/internal/pycore_uop_ids.h

Lines changed: 48 additions & 43 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎Include/internal/pycore_uop_metadata.h

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

‎Lib/test/lock_tests.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,26 @@ class RLockTests(BaseLockTests):
337337
"""
338338
Tests for recursive locks.
339339
"""
340+
deftest_repr_count(self):
341+
# see gh-134322: check that count values are correct:
342+
# when a rlock is just created,
343+
# in a second thread when rlock is acquired in the main thread.
344+
lock=self.locktype()
345+
self.assertIn("count=0",repr(lock))
346+
self.assertIn("<unlocked",repr(lock))
347+
lock.acquire()
348+
lock.acquire()
349+
self.assertIn("count=2",repr(lock))
350+
self.assertIn("<locked",repr(lock))
351+
352+
result= []
353+
defcall_repr():
354+
result.append(repr(lock))
355+
withBunch(call_repr,1):
356+
pass
357+
self.assertIn("count=2",result[0])
358+
self.assertIn("<locked",result[0])
359+
340360
deftest_reacquire(self):
341361
lock=self.locktype()
342362
lock.acquire()

‎Lib/test/test_capi/test_opt.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2002,7 +2002,10 @@ def testfunc(n):
20022002
self.assertNotIn("_CALL_ISINSTANCE",uops)
20032003
self.assertNotIn("_GUARD_THIRD_NULL",uops)
20042004
self.assertNotIn("_GUARD_CALLABLE_ISINSTANCE",uops)
2005-
self.assertIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW",uops)
2005+
self.assertNotIn("_POP_TOP_LOAD_CONST_INLINE_BORROW",uops)
2006+
self.assertNotIn("_POP_CALL_LOAD_CONST_INLINE_BORROW",uops)
2007+
self.assertNotIn("_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW",uops)
2008+
self.assertNotIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW",uops)
20062009

20072010
deftest_call_list_append(self):
20082011
deftestfunc(n):
@@ -2035,7 +2038,10 @@ def testfunc(n):
20352038
self.assertNotIn("_CALL_ISINSTANCE",uops)
20362039
self.assertNotIn("_TO_BOOL_BOOL",uops)
20372040
self.assertNotIn("_GUARD_IS_TRUE_POP",uops)
2038-
self.assertIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW",uops)
2041+
self.assertNotIn("_POP_TOP_LOAD_CONST_INLINE_BORROW",uops)
2042+
self.assertNotIn("_POP_CALL_LOAD_CONST_INLINE_BORROW",uops)
2043+
self.assertNotIn("_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW",uops)
2044+
self.assertNotIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW",uops)
20392045

20402046
deftest_call_isinstance_is_false(self):
20412047
deftestfunc(n):
@@ -2053,7 +2059,10 @@ def testfunc(n):
20532059
self.assertNotIn("_CALL_ISINSTANCE",uops)
20542060
self.assertNotIn("_TO_BOOL_BOOL",uops)
20552061
self.assertNotIn("_GUARD_IS_FALSE_POP",uops)
2056-
self.assertIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW",uops)
2062+
self.assertNotIn("_POP_TOP_LOAD_CONST_INLINE_BORROW",uops)
2063+
self.assertNotIn("_POP_CALL_LOAD_CONST_INLINE_BORROW",uops)
2064+
self.assertNotIn("_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW",uops)
2065+
self.assertNotIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW",uops)
20572066

20582067
deftest_call_isinstance_subclass(self):
20592068
deftestfunc(n):
@@ -2071,7 +2080,10 @@ def testfunc(n):
20712080
self.assertNotIn("_CALL_ISINSTANCE",uops)
20722081
self.assertNotIn("_TO_BOOL_BOOL",uops)
20732082
self.assertNotIn("_GUARD_IS_TRUE_POP",uops)
2074-
self.assertIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW",uops)
2083+
self.assertNotIn("_POP_TOP_LOAD_CONST_INLINE_BORROW",uops)
2084+
self.assertNotIn("_POP_CALL_LOAD_CONST_INLINE_BORROW",uops)
2085+
self.assertNotIn("_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW",uops)
2086+
self.assertNotIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW",uops)
20752087

20762088
deftest_call_isinstance_unknown_object(self):
20772089
deftestfunc(n):

‎Lib/test/test_importlib/test_locks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class ModuleLockAsRLockTests:
3434
# lock status in repr unsupported
3535
test_repr=None
3636
test_locked_repr=None
37+
test_repr_count=None
3738

3839
deftearDown(self):
3940
forsplitinitininit.values():
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Optimize ``_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW``.

‎Modules/_interpchannelsmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3443,7 +3443,7 @@ channelsmod_get_channel_defaults(PyObject *self, PyObject *args, PyObject *kwds)
34433443
}
34443444
int64_tcid=cid_data.cid;
34453445

3446-
struct_channeldefaultsdefaults;
3446+
struct_channeldefaultsdefaults= {0};
34473447
interr=channel_get_defaults(&_globals.channels,cid,&defaults);
34483448
if (handle_channel_error(err,self,cid)) {
34493449
returnNULL;

‎Modules/_interpqueuesmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1772,7 +1772,7 @@ queuesmod_get_queue_defaults(PyObject *self, PyObject *args, PyObject *kwds)
17721772
}
17731773
int64_tqid=qidarg.id;
17741774

1775-
struct_queuedefaultsdefaults;
1775+
struct_queuedefaultsdefaults= {0};
17761776
interr=queue_get_defaults(&_globals.queues,qid,&defaults);
17771777
if (handle_queue_error(err,self,qid)) {
17781778
returnNULL;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp