mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
312 test fix in named tensor and TS deprecations (#113981)
Fix existing bugs / deprecations that become hard errors when running CI with Python 3.12 Pull Request resolved: https://github.com/pytorch/pytorch/pull/113981 Approved by: https://github.com/malfet
This commit is contained in:
parent
4667e20b3f
commit
855a5cf427
2 changed files with 13 additions and 7 deletions
|
|
@ -7,6 +7,7 @@ namespace torch {
|
|||
|
||||
struct InternedStringsTable {
|
||||
InternedStringsTable() = default;
|
||||
// NOLINTNEXTLINE(bugprone-exception-escape)
|
||||
~InternedStringsTable();
|
||||
InternedStringsTable(const InternedStringsTable&) = delete;
|
||||
InternedStringsTable& operator=(InternedStringsTable const&) = delete;
|
||||
|
|
@ -23,12 +24,17 @@ struct InternedStringsTable {
|
|||
|
||||
InternedStringsTable kPyInternedStringToDimname;
|
||||
|
||||
// NOLINTNEXTLINE(bugprone-exception-escape)
|
||||
InternedStringsTable::~InternedStringsTable() {
|
||||
for (auto it = py_interned_string_to_dimname_.begin();
|
||||
it != py_interned_string_to_dimname_.end();
|
||||
++it) {
|
||||
// See Note [References to python interned strings]
|
||||
Py_DECREF(it->first);
|
||||
// If python is already dead, leak the wrapped python objects
|
||||
if (Py_IsInitialized()) {
|
||||
pybind11::gil_scoped_acquire gil;
|
||||
for (auto it = py_interned_string_to_dimname_.begin();
|
||||
it != py_interned_string_to_dimname_.end();
|
||||
++it) {
|
||||
// See Note [References to python interned strings]
|
||||
Py_DECREF(it->first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1162,7 +1162,7 @@ class ExprBuilder(Builder):
|
|||
|
||||
@staticmethod
|
||||
def build_Num(ctx, expr):
|
||||
value = str(expr.n)
|
||||
value = str(expr.value)
|
||||
r = ctx.make_range(expr.lineno, expr.col_offset, expr.col_offset + len(value))
|
||||
return Const(r, value)
|
||||
|
||||
|
|
@ -1187,7 +1187,7 @@ class ExprBuilder(Builder):
|
|||
|
||||
@staticmethod
|
||||
def build_Str(ctx, expr):
|
||||
value = str(expr.s)
|
||||
value = str(expr.value)
|
||||
r = ctx.make_range(
|
||||
expr.lineno, expr.col_offset, expr.col_offset + len(value) + 1
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue