[issue46903] Crash when setting attribute with string subclass as the name (--with-pydebug)

2022-03-06 Thread Dennis Sweeney


Change by Dennis Sweeney :


--
pull_requests: +29833
pull_request: https://github.com/python/cpython/pull/31718

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46903] Crash when setting attribute with string subclass as the name (--with-pydebug)

2022-03-06 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

The PR introduced some deprecation warnings in tests.

./python -Wall -m test test_unicode   
0:00:00 load avg: 1.54 Run tests sequentially
0:00:00 load avg: 1.54 [1/1] test_unicode
/home/karthikeyan/stuff/python/cpython/Lib/test/test_unicode.py:3058: 
DeprecationWarning: Please use assertEqual instead.
  self.assertEquals(o.name, 1)
/home/karthikeyan/stuff/python/cpython/Lib/test/test_unicode.py:3060: 
DeprecationWarning: Please use assertEqual instead.
  self.assertEquals(list(o.__dict__), [name])
/home/karthikeyan/stuff/python/cpython/Lib/test/test_unicode.py:3067: 
DeprecationWarning: Please use assertEqual instead.
  self.assertEquals(o.name2, 3)
/home/karthikeyan/stuff/python/cpython/Lib/test/test_unicode.py:3069: 
DeprecationWarning: Please use assertEqual instead.
  self.assertEquals(list(o.__dict__), [name, name2])

== Tests result: SUCCESS ==

1 test OK.

Total duration: 952 ms
Tests result: SUCCESS

--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46903] Crash when setting attribute with string subclass as the name (--with-pydebug)

2022-03-06 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

Your PR fixed the issue for me.

--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46903] Crash when setting attribute with string subclass as the name (--with-pydebug)

2022-03-06 Thread Mark Shannon


Mark Shannon  added the comment:

Ronald, does PR 31658 fix your issue?

--
stage: patch review -> 

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46903] Crash when setting attribute with string subclass as the name (--with-pydebug)

2022-03-04 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 03c2a36b2bd2d4469160d1607619ee144175d753 by Mark Shannon in 
branch 'main':
bpo-46903: Handle str-subclasses in virtual instance dictionaries. (GH-31658)
https://github.com/python/cpython/commit/03c2a36b2bd2d4469160d1607619ee144175d753


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46903] Crash when setting attribute with string subclass as the name (--with-pydebug)

2022-03-03 Thread Mark Shannon


Change by Mark Shannon :


--
keywords: +patch
pull_requests: +29776
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/31658

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46903] Crash when setting attribute with string subclass as the name (--with-pydebug)

2022-03-02 Thread Inada Naoki


Change by Inada Naoki :


--
nosy: +methane

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46903] Crash when setting attribute with string subclass as the name (--with-pydebug)

2022-03-02 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

a8b9350964f43cb648c98c179c8037fbf3ff8a7d is the first bad commit
commit a8b9350964f43cb648c98c179c8037fbf3ff8a7d
Author: Mark Shannon 
Date:   Wed Oct 13 14:19:34 2021 +0100

bpo-45340: Don't create object dictionaries unless actually needed 
(GH-28802)

* Never change types' cached keys. It could invalidate inline attribute 
objects.

* Lazily create object dictionaries.

* Update specialization of LOAD/STORE_ATTR.

* Don't update shared keys version for deletion of value.

* Update gdb support to handle instance values.

* Rename SPLIT_KEYS opcodes to INSTANCE_VALUE.

--
nosy: +Dennis Sweeney, Mark.Shannon

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46903] Crash when setting attribute with string subclass as the name (--with-pydebug)

2022-03-02 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

A hard crash seems wrong to me, and I'm not convinced yet that checking that 
the type of the attribute name is exactly string is correct.

Found while debugging a crash in PyObjC's testsuite, PyObjC uses a subclass of 
str to represent Objective-C strings.  Using such instances works fine in 
practice, but causes a crash in a --with-pydebug build due to this assertion.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46903] Crash when setting attribute with string subclass as the name (--with-pydebug)

2022-03-02 Thread Ronald Oussoren


New submission from Ronald Oussoren :

The script below fails with an assertion error with python 3.11a5+ (current 
trunk) when build with --with-pydebug:

# BEGIN OF FILE
class String(str):
__slots__ = ()

name = String("hello")

class Bag:
pass

o = Bag()
setattr(o, name, 42)

# END OF FILE

Error output:

% /tmp/py311/bin/python3 -Xdev str.py   
  
(master)pyobjc-8
Assertion failed: (PyUnicode_CheckExact(name)), function 
_PyObject_StoreInstanceAttribute, file dictobject.c, line 5426.
Fatal Python error: Aborted

Current thread 0x000100a98580 (most recent call first):
  File "/Users/ronald/Projects/pyobjc-8/pyobjc-core/str.py", line 10 in 
zsh: abort  /tmp/py311/bin/python3 -Xdev str.py

--
components: Interpreter Core
messages: 414386
nosy: ronaldoussoren
priority: normal
severity: normal
status: open
title: Crash when setting attribute with string subclass as the name 
(--with-pydebug)
type: crash
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com