Skip to content

Commit 63b1696

Browse files
authored
Derive name from tp_name
1 parent 14405b7 commit 63b1696

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+180
-185
lines changed

Lib/test/test_reprlib.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ class bar:
318318
# Module name may be prefixed with "test.", depending on how run.
319319
self.assertEqual(repr(bar.bar), "<class '%s.bar'>" % bar.__name__)
320320

321+
# TODO: RUSTPYTHON
322+
@unittest.expectedFailure
321323
def test_instance(self):
322324
self._check_path_limitations('baz')
323325
write_file(os.path.join(self.subpkgname, 'baz.py'), '''\
@@ -330,6 +332,8 @@ class baz:
330332
self.assertTrue(repr(ibaz).startswith(
331333
"<%s.baz object at 0x" % baz.__name__))
332334

335+
# TODO: RUSTPYTHON
336+
@unittest.expectedFailure
333337
def test_method(self):
334338
self._check_path_limitations('qux')
335339
eq = self.assertEqual

Lib/test/test_socket.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,6 +1557,8 @@ def test_dealloc_warn(self):
15571557
f = None
15581558
support.gc_collect()
15591559

1560+
# TODO: RUSTPYTHON
1561+
@unittest.expectedFailure
15601562
def test_name_closed_socketio(self):
15611563
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
15621564
fp = sock.makefile("rb")

vm/src/buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl TryFromBorrowedObject for PyBufferRef {
8383
}
8484
Err(vm.new_type_error(format!(
8585
"a bytes-like object is required, not '{}'",
86-
obj_cls.name
86+
obj_cls.name()
8787
)))
8888
}
8989
}

vm/src/builtins/builtinfunc.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ impl PyBuiltinMethod {
209209
}
210210
#[pyproperty(magic)]
211211
fn qualname(&self) -> String {
212-
format!("{}.{}", self.class.name, &self.value.name)
212+
format!("{}.{}", self.class.name(), &self.value.name)
213213
}
214214
#[pyproperty(magic)]
215215
fn doc(&self) -> Option<PyStrRef> {
@@ -226,7 +226,8 @@ impl PyBuiltinMethod {
226226
fn repr(&self) -> String {
227227
format!(
228228
"<method '{}' of '{}' objects>",
229-
&self.value.name, self.class.name
229+
&self.value.name,
230+
self.class.name()
230231
)
231232
}
232233
}

vm/src/builtins/bytes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,8 @@ impl Comparable for PyBytes {
575575
return Err(vm.new_type_error(format!(
576576
"'{}' not supported between instances of '{}' and '{}'",
577577
op.operator_token(),
578-
zelf.class().name,
579-
other.class().name
578+
zelf.class().name(),
579+
other.class().name()
580580
)));
581581
} else {
582582
zelf.inner.cmp(other, op, vm)

vm/src/builtins/complex.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl SlotConstructor for PyComplex {
117117
} else {
118118
return Err(vm.new_type_error(format!(
119119
"complex() first argument must be a string or a number, not '{}'",
120-
val.class().name
120+
val.class().name()
121121
)));
122122
}
123123
}
@@ -137,7 +137,7 @@ impl SlotConstructor for PyComplex {
137137
} else {
138138
return Err(vm.new_type_error(format!(
139139
"complex() second argument must be a number, not '{}'",
140-
obj.class().name
140+
obj.class().name()
141141
)));
142142
}
143143
}
@@ -437,7 +437,7 @@ fn try_complex(obj: &PyObjectRef, vm: &VirtualMachine) -> PyResult<Option<(Compl
437437
Some(complex_obj) => Ok(Some((complex_obj.value, true))),
438438
None => Err(vm.new_type_error(format!(
439439
"__complex__ returned non-complex (type '{}')",
440-
result.class().name
440+
result.class().name()
441441
))),
442442
};
443443
}

vm/src/builtins/float.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub fn try_float_opt(obj: &PyObjectRef, vm: &VirtualMachine) -> PyResult<Option<
6262
Some(float_obj) => Ok(Some(float_obj.value)),
6363
None => Err(vm.new_type_error(format!(
6464
"__float__ returned non-float (type '{}')",
65-
result.class().name
65+
result.class().name()
6666
))),
6767
};
6868
}
@@ -73,8 +73,9 @@ pub fn try_float_opt(obj: &PyObjectRef, vm: &VirtualMachine) -> PyResult<Option<
7373
}
7474

7575
pub fn try_float(obj: &PyObjectRef, vm: &VirtualMachine) -> PyResult<f64> {
76-
try_float_opt(obj, vm)?
77-
.ok_or_else(|| vm.new_type_error(format!("must be real number, not {}", obj.class().name)))
76+
try_float_opt(obj, vm)?.ok_or_else(|| {
77+
vm.new_type_error(format!("must be real number, not {}", obj.class().name()))
78+
})
7879
}
7980

8081
pub(crate) fn to_op_float(obj: &PyObjectRef, vm: &VirtualMachine) -> PyResult<Option<f64>> {
@@ -186,7 +187,7 @@ impl SlotConstructor for PyFloat {
186187
} else {
187188
return Err(vm.new_type_error(format!(
188189
"float() argument must be a string or a number, not '{}'",
189-
val.class().name
190+
val.class().name()
190191
)));
191192
}
192193
}

vm/src/builtins/getset.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ impl SlotDescriptor for PyGetSet {
259259
Err(vm.new_attribute_error(format!(
260260
"attribute '{}' of '{}' objects is not readable",
261261
zelf.name,
262-
Self::class(vm).name
262+
Self::class(vm).name()
263263
)))
264264
}
265265
}
@@ -321,7 +321,7 @@ impl PyGetSet {
321321
Err(vm.new_attribute_error(format!(
322322
"attribute '{}' of '{}' objects is not writable",
323323
zelf.name,
324-
obj.class().name
324+
obj.class().name()
325325
)))
326326
}
327327
}
@@ -332,7 +332,7 @@ impl PyGetSet {
332332
Err(vm.new_attribute_error(format!(
333333
"attribute '{}' of '{}' objects is not writable",
334334
zelf.name,
335-
obj.class().name
335+
obj.class().name()
336336
)))
337337
}
338338
}

vm/src/builtins/int.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -509,13 +509,13 @@ impl PyInt {
509509
let _ndigits = value.payload_if_subclass::<PyInt>(vm).ok_or_else(|| {
510510
vm.new_type_error(format!(
511511
"'{}' object cannot be interpreted as an integer",
512-
value.class().name
512+
value.class().name()
513513
))
514514
})?;
515515
} else {
516516
return Err(vm.new_type_error(format!(
517517
"'{}' object cannot be interpreted as an integer",
518-
value.class().name
518+
value.class().name()
519519
)));
520520
}
521521
}
@@ -948,7 +948,7 @@ pub(crate) fn try_int(obj: &PyObjectRef, vm: &VirtualMachine) -> PyResult<BigInt
948948
Some(int_obj) => Ok(int_obj.as_bigint().clone()),
949949
None => Err(vm.new_type_error(format!(
950950
"__int__ returned non-int (type '{}')",
951-
result.class().name
951+
result.class().name()
952952
))),
953953
};
954954
}
@@ -963,15 +963,15 @@ pub(crate) fn try_int(obj: &PyObjectRef, vm: &VirtualMachine) -> PyResult<BigInt
963963
.unwrap_or_else(|| {
964964
Err(vm.new_type_error(format!(
965965
"__trunc__ returned non-Integral (type '{}')",
966-
result.class().name
966+
result.class().name()
967967
)))
968968
})
969969
.map(|int_obj| int_obj.as_bigint().clone());
970970
}
971971

972972
Err(vm.new_type_error(format!(
973973
"int() argument must be a string, a bytes-like object or a number, not '{}'",
974-
obj.class().name
974+
obj.class().name()
975975
)))
976976
}
977977

vm/src/builtins/list.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ impl PyList {
114114
} else {
115115
Err(vm.new_type_error(format!(
116116
"Cannot add {} and {}",
117-
Self::class(vm).name,
118-
other.class().name
117+
Self::class(vm).name(),
118+
other.class().name()
119119
)))
120120
}
121121
}

0 commit comments

Comments
 (0)