[issue46693] dataclass generated __str__ does not use overridden member __str__

2022-02-09 Thread Bruce Eckel


New submission from Bruce Eckel :

When creating a dataclass using members of other classes that have overridden 
their __str__ methods, the __str__ method synthesized by the dataclass ignores 
the overridden __str__ methods in its component members.

Demonstrated in attached file.

--
components: Interpreter Core
files: DataClassStrBug.py
messages: 412927
nosy: Bruce Eckel
priority: normal
severity: normal
status: open
title: dataclass generated __str__ does not use overridden member __str__
type: behavior
versions: Python 3.10
Added file: https://bugs.python.org/file50611/DataClassStrBug.py

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



[issue46693] dataclass generated __str__ does not use overridden member __str__

2022-02-09 Thread Bruce Eckel


Bruce Eckel  added the comment:

Oops. That does in fact work. How do I remove the bug report?

*Bruce Eckel*
HappyPathProgramming.com
SummerTechForum.com
MindViewLLC.com
Blog: BruceEckel.com
EvolveWork.co
WinterTechForum.com <http://www.WinterTechForum.com>
OnJava8.com <http://www.OnJava8.com>
www.AtomicKotlin.com
Reinventing-Business.com <http://www.Reinventing-Business.com>

On Wed, Feb 9, 2022 at 10:20 AM Eric V. Smith 
wrote:

>
> Eric V. Smith  added the comment:
>
> I believe dataclasses uses repr() of the members, not str(). Can you try
> using specifying __repr__ in Teacup? Just __repr__ = __str__ should work.
>
> --
> nosy: +eric.smith
>
> ___
> Python tracker 
> <https://bugs.python.org/issue46693>
> ___
>

--

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



[issue27586] Is this a regular expression library bug?

2016-07-21 Thread Bruce Eckel

New submission from Bruce Eckel:

This looks suspicious to me, like it could be a library bug, but before chasing 
it down I was hoping someone might be able to tell me whether I might be on to 
something:

Traceback (most recent call last):
  File "update_extracted_example_output.py", line 22, in 
new_javatext = find_output.sub(new_output, javatext)
  File "C:\Python35\lib\re.py", line 325, in _subx
template = _compile_repl(template, pattern)
  File "C:\Python35\lib\re.py", line 312, in _compile_repl
p = sre_parse.parse_template(repl, pattern)
  File "C:\Python35\lib\sre_parse.py", line 872, in parse_template
raise s.error("missing <")
sre_constants.error: missing < at position 100 (line 4, column 41)

--
components: Library (Lib)
messages: 270956
nosy: Bruce Eckel
priority: normal
severity: normal
status: open
title: Is this a regular expression library bug?
type: compile error
versions: Python 3.5

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



[issue27586] Is this a regular expression library bug?

2016-07-21 Thread Bruce Eckel

Bruce Eckel added the comment:

Sorry, I thought maybe the error message would be indicative of something. 
Here's the re:

find_output = re.compile(r"/\* (Output:.*)\*/", re.DOTALL)

Here's the program:

#! py -3
# Requires Python 3.5
# Updates generated output into extracted Java programs in "On Java 8"
from pathlib import Path
import re
import pprint
import sys

if __name__ == '__main__':
find_output = re.compile(r"/\* (Output:.*)\*/", re.DOTALL)
for outfile in Path(".").rglob("*.p1"):
print(str(outfile))
javafile = outfile.with_suffix(".java")
if not javafile.exists():
print(str(outfile) + " has no javafile")
sys.exit(1)
javatext = javafile.read_text()
if "/* Output:" not in javatext:
print(str(javafile) + " has no /* Output:")
sys.exit(1)
new_output = outfile.read_text()
new_javatext = find_output.sub(new_output, javatext)
javafile.write_text(new_javatext)

--

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



[issue27586] Is this a regular expression library bug?

2016-07-21 Thread Bruce Eckel

Bruce Eckel added the comment:

Urk. There was exactly a \g in the input. Sorry for the bother.

--
resolution:  -> not a bug

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



[issue27586] Is this a regular expression library bug?

2016-07-22 Thread Bruce Eckel

Bruce Eckel added the comment:

Thank you ebarry, very helpful. Tim, sorry I missed you at Pycon.

--

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