##// END OF EJS Templates
rust-cpython: require GIL to borrow immutable reference from PySharedRefCell...
Yuya Nishihara -
r43580:f8c114f2 default
parent child Browse files
Show More
@@ -100,7 +100,7 b' py_class!(pub class Dirs |py| {'
100 100 }
101 101
102 102 def __contains__(&self, item: PyObject) -> PyResult<bool> {
103 Ok(self.inner(py).borrow().contains(HgPath::new(
103 Ok(self.inner_shared(py).borrow().contains(HgPath::new(
104 104 item.extract::<PyBytes>(py)?.data(py).as_ref(),
105 105 )))
106 106 }
@@ -63,7 +63,7 b' py_class!(pub class DirstateMap |py| {'
63 63 default: Option<PyObject> = None
64 64 ) -> PyResult<Option<PyObject>> {
65 65 let key = key.extract::<PyBytes>(py)?;
66 match self.inner(py).borrow().get(HgPath::new(key.data(py))) {
66 match self.inner_shared(py).borrow().get(HgPath::new(key.data(py))) {
67 67 Some(entry) => {
68 68 Ok(Some(make_dirstate_tuple(py, entry)?))
69 69 },
@@ -170,7 +170,7 b' py_class!(pub class DirstateMap |py| {'
170 170 // TODO share the reference
171 171 def nonnormalentries(&self) -> PyResult<PyObject> {
172 172 let (non_normal, other_parent) =
173 self.inner(py).borrow().non_normal_other_parent_entries();
173 self.inner_shared(py).borrow().non_normal_other_parent_entries();
174 174
175 175 let locals = PyDict::new(py);
176 176 locals.set_item(
@@ -281,18 +281,18 b' py_class!(pub class DirstateMap |py| {'
281 281 }
282 282
283 283 def __len__(&self) -> PyResult<usize> {
284 Ok(self.inner(py).borrow().len())
284 Ok(self.inner_shared(py).borrow().len())
285 285 }
286 286
287 287 def __contains__(&self, key: PyObject) -> PyResult<bool> {
288 288 let key = key.extract::<PyBytes>(py)?;
289 Ok(self.inner(py).borrow().contains_key(HgPath::new(key.data(py))))
289 Ok(self.inner_shared(py).borrow().contains_key(HgPath::new(key.data(py))))
290 290 }
291 291
292 292 def __getitem__(&self, key: PyObject) -> PyResult<PyObject> {
293 293 let key = key.extract::<PyBytes>(py)?;
294 294 let key = HgPath::new(key.data(py));
295 match self.inner(py).borrow().get(key) {
295 match self.inner_shared(py).borrow().get(key) {
296 296 Some(entry) => {
297 297 Ok(make_dirstate_tuple(py, entry)?)
298 298 },
@@ -333,7 +333,7 b' py_class!(pub class DirstateMap |py| {'
333 333 Dirs::from_inner(
334 334 py,
335 335 DirsMultiset::from_dirstate(
336 &self.inner(py).borrow(),
336 &self.inner_shared(py).borrow(),
337 337 Some(EntryState::Removed),
338 338 ),
339 339 )
@@ -344,7 +344,7 b' py_class!(pub class DirstateMap |py| {'
344 344 Dirs::from_inner(
345 345 py,
346 346 DirsMultiset::from_dirstate(
347 &self.inner(py).borrow(),
347 &self.inner_shared(py).borrow(),
348 348 None,
349 349 ),
350 350 )
@@ -353,7 +353,7 b' py_class!(pub class DirstateMap |py| {'
353 353 // TODO all copymap* methods, see docstring above
354 354 def copymapcopy(&self) -> PyResult<PyDict> {
355 355 let dict = PyDict::new(py);
356 for (key, value) in self.inner(py).borrow().copy_map.iter() {
356 for (key, value) in self.inner_shared(py).borrow().copy_map.iter() {
357 357 dict.set_item(
358 358 py,
359 359 PyBytes::new(py, key.as_ref()),
@@ -365,7 +365,7 b' py_class!(pub class DirstateMap |py| {'
365 365
366 366 def copymapgetitem(&self, key: PyObject) -> PyResult<PyBytes> {
367 367 let key = key.extract::<PyBytes>(py)?;
368 match self.inner(py).borrow().copy_map.get(HgPath::new(key.data(py))) {
368 match self.inner_shared(py).borrow().copy_map.get(HgPath::new(key.data(py))) {
369 369 Some(copy) => Ok(PyBytes::new(py, copy.as_ref())),
370 370 None => Err(PyErr::new::<exc::KeyError, _>(
371 371 py,
@@ -378,12 +378,12 b' py_class!(pub class DirstateMap |py| {'
378 378 }
379 379
380 380 def copymaplen(&self) -> PyResult<usize> {
381 Ok(self.inner(py).borrow().copy_map.len())
381 Ok(self.inner_shared(py).borrow().copy_map.len())
382 382 }
383 383 def copymapcontains(&self, key: PyObject) -> PyResult<bool> {
384 384 let key = key.extract::<PyBytes>(py)?;
385 385 Ok(self
386 .inner(py)
386 .inner_shared(py)
387 387 .borrow()
388 388 .copy_map
389 389 .contains_key(HgPath::new(key.data(py))))
@@ -395,7 +395,7 b' py_class!(pub class DirstateMap |py| {'
395 395 ) -> PyResult<Option<PyObject>> {
396 396 let key = key.extract::<PyBytes>(py)?;
397 397 match self
398 .inner(py)
398 .inner_shared(py)
399 399 .borrow()
400 400 .copy_map
401 401 .get(HgPath::new(key.data(py)))
@@ -136,7 +136,7 b' impl<T> PySharedRefCell<T> {'
136 136 }
137 137 }
138 138
139 pub fn borrow(&self) -> Ref<T> {
139 pub fn borrow<'a>(&'a self, _py: Python<'a>) -> Ref<'a, T> {
140 140 // py_shared_state isn't involved since
141 141 // - inner.borrow() would fail if self is mutably borrowed,
142 142 // - and inner.borrow_mut() would fail while self is borrowed.
@@ -180,7 +180,7 b" impl<'a, T> PySharedRef<'a, T> {"
180 180 }
181 181
182 182 pub fn borrow(&self) -> Ref<'a, T> {
183 self.data.borrow()
183 self.data.borrow(self.py)
184 184 }
185 185
186 186 pub fn borrow_mut(&self) -> PyResult<PyRefMut<'a, T>> {
General Comments 0
You need to be logged in to leave comments. Login now