Title: Clear Element children when replacing extra state by youknowdot · Pull Request #9624 · RustPython/RustPython · GitHub
Open Graph Title: Clear Element children when replacing extra state by youknowdot · Pull Request #9624 · RustPython/RustPython
X Title: Clear Element children when replacing extra state by youknowdot · Pull Request #9624 · RustPython/RustPython
Description: Summary When an Element is reinitialized with a nonempty attribute mapping, replace its extra state and clear existing children. As in CPython, reinitialization with no attributes or an empty mapping preserves the existing attributes and children. Displaced RustPython references are released after the element lock is dropped. Lifetime distinction CPython 3.15.0's element_init calls create_extra, which overwrites the old extra pointer on this unusual reinitialization path without freeing it. A CPython weak-reference check confirms the detached child remains alive. This change intentionally releases the displaced state instead of reproducing that leak, so finalizer timing and reentrant side effects can differ from CPython. Validation CPython 3.15.0 reproductions checked absent, empty and nonempty attribute mappings, child counts, attribute identity, text/tail reset and detached-child lifetime. Independent source review and normal commit hooks (including rustfmt) passed. Sequential local three-way file merges with #9591, #9594 and #9598 were clean. RustPython was not built or executed locally. No tests were added or changed; hosted CI is expected to run existing ElementTree tests. Summary by CodeRabbit Bug Fixes Element initialization now preserves existing attributes when no nonempty attributes are provided. When nonempty attributes are provided, initialization now clears existing children along with replacing attributes.
Open Graph Description: Summary When an Element is reinitialized with a nonempty attribute mapping, replace its extra state and clear existing children. As in CPython, reinitialization with no attributes or an empty mappi...
X Description: Summary When an Element is reinitialized with a nonempty attribute mapping, replace its extra state and clear existing children. As in CPython, reinitialization with no attributes or an empty mappi...
Opengraph URL: https://github.com/RustPython/RustPython/pull/9624
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:d48dcbd2-7af8-7f63-e062-78a69accfa88 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | BA04:31E99C:35EE89C:47E62CB:6B020873 |
| html-safe-nonce | 831006a2a5cea750b8ade70ef31bd904f32be3648492b050b4c6fb2c07a4f958 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQTA0OjMxRTk5QzozNUVFODlDOjQ3RTYyQ0I6NkIwMjA4NzMiLCJ2aXNpdG9yX2lkIjoiMjg2OTAzNDEzMTEzODkzODk5NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d36acf64acbe1b6f680b0d18fe50690c6b7e1f2417205949824b90c86ed02ab4 |
| hovercard-subject-tag | pull_request:5138174518 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/RustPython/RustPython/pull/9624/files |
| twitter:image | https://avatars.githubusercontent.com/u/336763669?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/336763669?s=400&v=4 |
| og:image:alt | Summary When an Element is reinitialized with a nonempty attribute mapping, replace its extra state and clear existing children. As in CPython, reinitialization with no attributes or an empty mappi... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width