[issue43828] MappingProxyType accepts string

2021-04-13 Thread Andy Maier


Andy Maier  added the comment:

I accept that the issue was closed, but wanted to document some things:

1. The dict class manages very well to detect that a string is invalid input:

>>> d = dict('abc')
Traceback (most recent call last):
  File "", line 1, in 
ValueError: dictionary update sequence element #0 has length 1; 2 is required

2. When initialized with strings, it looses some of its dictionary methods, but 
does a quite reasonable job in pointing that out in the error message:

>>> mp = MappingProxyType('abc')
>>> mp.items()
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'str' object has no attribute 'items'

--

___
Python tracker 

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



[issue43777] Remove description of "pip search" command from tutorial

2021-04-13 Thread Inada Naoki


Change by Inada Naoki :


--
resolution:  -> fixed
stage: patch review -> 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



[issue43777] Remove description of "pip search" command from tutorial

2021-04-13 Thread miss-islington


miss-islington  added the comment:


New changeset 57873af35aad98c6428b1718aaee4b16a82ea3f5 by Miss Islington (bot) 
in branch '3.9':
bpo-43777: Drop description of "pip search" command from tutorial (GH-25287)
https://github.com/python/cpython/commit/57873af35aad98c6428b1718aaee4b16a82ea3f5


--

___
Python tracker 

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



[issue43777] Remove description of "pip search" command from tutorial

2021-04-13 Thread miss-islington


miss-islington  added the comment:


New changeset 6ac1ea25a2ba2aae742e191784cf73033b3ab332 by Miss Islington (bot) 
in branch '3.8':
bpo-43777: Drop description of "pip search" command from tutorial (GH-25287)
https://github.com/python/cpython/commit/6ac1ea25a2ba2aae742e191784cf73033b3ab332


--

___
Python tracker 

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



[issue43733] PEP 597: netrc uses locale encoding.

2021-04-13 Thread Inada Naoki


Change by Inada Naoki :


--
nosy: +xiang.zhang

___
Python tracker 

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



[issue43752] [sqlite3] Fetching an empty value from date column raises ValueError

2021-04-13 Thread Lumír Balhar

Change by Lumír Balhar :


--
nosy: +frenzy

___
Python tracker 

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



[issue42578] Add tip when encountering UnicodeDecode/EncodeError in open()

2021-04-13 Thread Inada Naoki


Change by Inada Naoki :


--
resolution:  -> wont fix
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



[issue41098] Deprecating PyUnicodeEncodeError_Create

2021-04-13 Thread Inada Naoki


Change by Inada Naoki :


--
resolution:  -> fixed
stage: patch review -> 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



[issue42152] Use PyDict_Contains() and PyDict_SetDefault() instead of PyDict_GetItemWithError()

2021-04-13 Thread Inada Naoki


Inada Naoki  added the comment:

May I close this issue?

--

___
Python tracker 

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



[issue5758] fileinput.hook_compressed returning bytes from gz file

2021-04-13 Thread Inada Naoki


Change by Inada Naoki :


--
resolution:  -> fixed
stage: patch review -> 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



[issue43712] PEP 597: fileinput uses locale encoding

2021-04-13 Thread Inada Naoki


Change by Inada Naoki :


--
resolution:  -> fixed
stage: patch review -> 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



[issue43712] PEP 597: fileinput uses locale encoding

2021-04-13 Thread Inada Naoki


Inada Naoki  added the comment:


New changeset 333d10cbb53dd5f28d76f659a49bf0735f8509d8 by Inada Naoki in branch 
'master':
bpo-43712 : fileinput: Add encoding parameter (GH-25272)
https://github.com/python/cpython/commit/333d10cbb53dd5f28d76f659a49bf0735f8509d8


--

___
Python tracker 

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



[issue43777] Remove description of "pip search" command from tutorial

2021-04-13 Thread miss-islington


Change by miss-islington :


--
pull_requests: +24131
pull_request: https://github.com/python/cpython/pull/25399

___
Python tracker 

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



[issue43777] Remove description of "pip search" command from tutorial

2021-04-13 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 4.0 -> 5.0
pull_requests: +24130
pull_request: https://github.com/python/cpython/pull/25398

___
Python tracker 

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



[issue43777] Remove description of "pip search" command from tutorial

2021-04-13 Thread Inada Naoki


Inada Naoki  added the comment:


New changeset 133705b85cc25d1e6684d32f8943ca288fadfda0 by Bob Kline in branch 
'master':
bpo-43777: Drop description of "pip search" command from tutorial (GH-25287)
https://github.com/python/cpython/commit/133705b85cc25d1e6684d32f8943ca288fadfda0


--

___
Python tracker 

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



[issue43837] Operator precedence documentation could be more clear

2021-04-13 Thread Aidan Feldman


New submission from Aidan Feldman :

I am teaching a class on Python for people who are new to coding, and I was 
talking them through the operator precedence table:

https://docs.python.org/3/reference/expressions.html#operator-precedence

A couple things that confused the students:

- "Highest precedence" is on the bottom, while "lowest precedence" is on top
- There isn't any mention of variables. While not operators, probably worth 
mentioning that they (effectively?) have higher precedence than any of the 
operators.

I'd be happy to try making my first contribution to Python if there's interest 
in those edits. Also, I have an example breaking down operator precedence in 
practice here, which I could include:

https://colab.research.google.com/github/afeld/python-public-policy/blob/main/lecture_2.ipynb#scrollTo=UTxeT5RvqSFl

Thanks!

--
assignee: docs@python
components: Documentation
messages: 391030
nosy: aidan.feldman, docs@python
priority: normal
severity: normal
status: open
title: Operator precedence documentation could be more clear
type: enhancement
versions: Python 3.10, Python 3.9

___
Python tracker 

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



[issue32891] Add 'Integer' as synonym for 'Integral' in numbers module.

2021-04-13 Thread Sergey B Kirpichev


Change by Sergey B Kirpichev :


--
nosy: +Sergey.Kirpichev

___
Python tracker 

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



[issue43836] range.index doesn't support start/stop optional arguments

2021-04-13 Thread Kaleb Barrett


New submission from Kaleb Barrett :

The range builtin type is a collections.abc.Sequence, which in Python 3.5 added 
the optional start and stop arguments to the index method of Sequences. 
However, range.index does not support these optional arguments required by 
Sequence.

I noticed this when creating a wrapper type around range which was a  Sequence. 
mypy complained 'Signature of "index" incompatible with supertype "Sequence"', 
but attempting to pass the values raised 'TypeError: index() takes exactly one 
argument (3 given)'.

--
components: Library (Lib)
messages: 391029
nosy: ktbarrett
priority: normal
severity: normal
status: open
title: range.index doesn't support start/stop optional arguments
type: behavior
versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue43813] Denial of service on http.server module with large request method.

2021-04-13 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
nosy: +rhettinger

___
Python tracker 

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



[issue43829] MappingProxyType cannot hash a hashable underlying mapping

2021-04-13 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Serhiy, what do you think?  Would it make sense to pass through the underlying 
hash?  I don't think there is much use for this but don't see any particular 
reason to block it.

--
nosy: +rhettinger, serhiy.storchaka
priority: normal -> low
versions: +Python 3.10 -Python 3.9

___
Python tracker 

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



[issue43828] MappingProxyType accepts string

2021-04-13 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

This isn't a bug because the MappingProxy doesn't promise to do early detection 
and because it can't really be accomplished cleanly.

Perfect detection of non-mappings isn't possible.  Some easy, minimal checks 
are made for early detection using PyMapping_Check, PyList_Check, and 
PyTuple_Check.  Anything that gets past those checks will just need to be 
duck-typed downstream when it is used.

We could add a few other specific exclusions but that isn't a general solution 
and it slows down instantiation.  Further it could break code that is intended 
to work (subclasses of str that mapping methods) or that just happen to work:

>>> from types import MappingProxyType
>>> mp = MappingProxyType('abc')
>>> mp[0]
'a'

--
nosy: +rhettinger
resolution:  -> not a bug
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



Re: [ANN] Free Python tutorial with exercises, cscx.org

2021-04-13 Thread Russell via Python-list
Jach Feng  wrote:
 
> Is there any reason a student/beginner learn Python now start from Python2?
> 
> --Jach

Only if you want a job porting python2 to python3. Python 2.x is
officially End Of Life.

-- 
rust
0x68caecc97f6a90122e51c0692c88d9cb6b58a3dc
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue38530] Offer suggestions on AttributeError and NameError

2021-04-13 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +24129
pull_request: https://github.com/python/cpython/pull/25397

___
Python tracker 

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



Re: UI design: combobox or radiobuttons?

2021-04-13 Thread Rich Shepard

On Wed, 14 Apr 2021, Alan Gauld via Python-list wrote:


readability? If the combo box puts the units immediately beside the value
then it will be more readable than if it is a row of radio buttons
above/below or beside the value.

But if the radio buttons represent a unit choice that applies to all
values on the screen then that is more noticeable and thus more readable
than a single small combobox choice lurking in a corner somewhere.


Excellent points, Alan.

Thanks very much,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


[issue38530] Offer suggestions on AttributeError and NameError

2021-04-13 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
title: Offer suggestions on AttributeError -> Offer suggestions on 
AttributeError and NameError

___
Python tracker 

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



[issue38530] Offer suggestions on AttributeError

2021-04-13 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 37494b441aced0362d7edd2956ab3ea7801e60c8 by Pablo Galindo in 
branch 'master':
bpo-38530: Offer suggestions on AttributeError (#16856)
https://github.com/python/cpython/commit/37494b441aced0362d7edd2956ab3ea7801e60c8


--

___
Python tracker 

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



[issue43680] Deprecate undocumented io.OpenWrapper and _pyio.OpenWrapper

2021-04-13 Thread STINNER Victor


Change by STINNER Victor :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
title: Remove undocumented io.OpenWrapper and _pyio.OpenWrapper -> Deprecate 
undocumented io.OpenWrapper and _pyio.OpenWrapper

___
Python tracker 

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



[issue43680] Remove undocumented io.OpenWrapper and _pyio.OpenWrapper

2021-04-13 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 3bc694d5f3d4eb2e5d2f0b83e498b19662845d4e by Victor Stinner in 
branch 'master':
bpo-43680: Deprecate io.OpenWrapper (GH-25357)
https://github.com/python/cpython/commit/3bc694d5f3d4eb2e5d2f0b83e498b19662845d4e


--

___
Python tracker 

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



[issue43680] Remove undocumented io.OpenWrapper and _pyio.OpenWrapper

2021-04-13 Thread Inada Naoki


Change by Inada Naoki :


--
pull_requests: +24128
pull_request: https://github.com/python/cpython/pull/25395

___
Python tracker 

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



[issue43682] Make static methods created by @staticmethod callable

2021-04-13 Thread Inada Naoki


Inada Naoki  added the comment:

Strictly speaking, adding any method is "potential" breaking change because 
hasattr(obj, "new_method") become from False to True. And since Python is 
dynamic language, any change is "potential" breaking change.

But we don't treat such change as breaking change. Practical beats purity.
We can use beta period to see is this change breaks real world application.

In case of staticmethod, I think creating a new thread in python-dev is ideal 
because it is language core feature. I will post a thread.

--

___
Python tracker 

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



[issue43835] Dataclasses don't call base class __init__

2021-04-13 Thread Eric V. Smith


Eric V. Smith  added the comment:

> The dataclass doesn't need to know what arguments the parent __init__ 
> accepts. It should consume the arguments it needs to initialize its instance 
> attributes, and forward the rest to the parent __init__.

The generated __init__() uses every parameter to initialize instance attributes 
(if we ignore InitVar). So are you saying it should call the base class with no 
parameters?

--

___
Python tracker 

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



[issue43835] Dataclasses don't call base class __init__

2021-04-13 Thread Paul Pinterits


Paul Pinterits  added the comment:

> dataclasses doesn't know the signature of the base class's __init__, so it 
> can't know how to call it.

The dataclass doesn't need to know what arguments the parent __init__ accepts. 
It should consume the arguments it needs to initialize its instance attributes, 
and forward the rest to the parent __init__.

> The typical way to handle this is for the derived class to add a 
> __post_init__() that calls into the base class's __init__().

How is that supposed to work? Like you said, the class doesn't know what 
arguments its parent constructor requires. If the derived class doesn't 
implement a custom __init__, @dataclass will generate one with an (probably) 
incorrect signature. Changing the signature is pretty much the only reason why 
you would need to implement a custom __init__, after all. For example:

```
@dataclasses.dataclass
class Foo:
foo: int

def __init__(self):
self.foo = 5

@dataclasses.dataclass
class Bar(Foo):
bar: int

def __post_init__(self):
super().__init__()

bar = Bar(1)  # TypeError: __init__() missing 1 required positional argument: 
'bar'
```

And even if this workaround actually worked, it would only be applicable if you 
*know* you're dealing with a dataclass and you'll have this problem. If you're 
writing something like a class decorator (similar to @dataclass), you don't 
know if the decorated class will be a dataclass or not. If it's a regular 
class, you can rely on the __init__s being chain-called. If it's a dataclass, 
you can't. Therefore, a class decorator that generates/replaces the __init__ 
method would need to take special care to be compatible with dataclasses, just 
because dataclasses don't follow basic OOP design principles.

Consider this trivial class decorator that generates an __init__ method:

```
def log_init(cls):
try:
original_init = vars(cls)['__init__']
except KeyError:
def original_init(self, *args, **kwargs):
super(cls, self).__init__(*args, **kwargs)

def __init__(self, *args, **kwargs):
print(f'{cls.__name__}.__init__ was called')
original_init(self, *args, **kwargs)

cls.__init__ = __init__
return cls

@log_init
@dataclasses.dataclass
class Foo:
foo: int

@dataclasses.dataclass
class Bar(Foo):
bar: int

Foo(1)  # Prints "Foo.__init__ was called"
Bar(1, 2)  # Prints nothing
```

How do you implement this in a way that is compatible with @dataclass?

--

___
Python tracker 

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



[issue43080] pprint for dataclass instances

2021-04-13 Thread Eric V. Smith


Eric V. Smith  added the comment:

Thanks for all of the work, LewisGaul.

--
resolution:  -> fixed
stage: patch review -> 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



[issue43080] pprint for dataclass instances

2021-04-13 Thread Eric V. Smith


Eric V. Smith  added the comment:


New changeset 11159d2c9d6616497ef4cc62953a5c3cc8454afb by Lewis Gaul in branch 
'master':
bpo-43080: pprint for dataclass instances (GH-24389)
https://github.com/python/cpython/commit/11159d2c9d6616497ef4cc62953a5c3cc8454afb


--

___
Python tracker 

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



[issue38755] Long unicode string causes SyntaxError: Non-UTF-8 code starting with '\xe2' in file ..., but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

2021-04-13 Thread STINNER Victor


STINNER Victor  added the comment:

In 2012, I wrote detect_truncate.patch in bpo-14811. Does someone want to 
convert it to a PR for Python 3.9?

--

___
Python tracker 

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



[issue38755] Long unicode string causes SyntaxError: Non-UTF-8 code starting with '\xe2' in file ..., but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

2021-04-13 Thread STINNER Victor


STINNER Victor  added the comment:

The bpo-14811 issue was fixed in Python 3.10 by bpo-25643, but is not fixed in 
Python 3.8 and 3.9.

--
nosy: +vstinner

___
Python tracker 

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



Re: UI design: combobox or radiobuttons?

2021-04-13 Thread Alan Gauld via Python-list
On 13/04/2021 22:53, Rich Shepard wrote:

> While a set of radiobuttons occupies more room on the parent widget than
> does a combobox are there any technical or user issues that would suggest
> using one over the other?

readability?
If the combo box puts the units immediately beside the value then
it will be more readable than if it is a row of radio buttons
above/below or beside the value.

But if the radio buttons represent a unit choice that applies
to all values on the screen then that is more noticeable and
thus more readable than a single small combobox choice
lurking in a corner somewhere.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


-- 
https://mail.python.org/mailman/listinfo/python-list


[issue14811] decoding_fgets() truncates long lines and fails with a SyntaxError("Non-UTF-8 code starting with...")

2021-04-13 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Ok, let's continue the discussion on https://bugs.python.org/issue38755

--

___
Python tracker 

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



[issue43731] PEP 597: logging.fileConfig() uses locale encoding.

2021-04-13 Thread Inada Naoki


Inada Naoki  added the comment:

> Ah, so you want to emit an EncodingWarning when fileConfig(filename) is 
> called without specifying an encoding, right?

Yes, but only when the user uses `PYTHONWARNDEFAULTENCODING`.

I already added `export PYTHONWARNDEFAULTENCODING=1` in `.bashrc` in my mac and 
Linux machine.

In the future, config file should be read with UTF-8 by default.

--

___
Python tracker 

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



[issue14811] decoding_fgets() truncates long lines and fails with a SyntaxError("Non-UTF-8 code starting with...")

2021-04-13 Thread Eryk Sun


Eryk Sun  added the comment:

> So that means we can close the issue, no?

This is a bug in 3.8 and 3.9, which need the fix to keep reading until "\n" is 
seen on the line. I arrived at this issue via bpo-38755 if you think it should 
be addressed there, but it's the same bug that's reported here.

--

___
Python tracker 

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



[issue43835] Dataclasses don't call base class __init__

2021-04-13 Thread Eric V. Smith


Eric V. Smith  added the comment:

dataclasses doesn't know the signature of the base class's __init__, so it 
can't know how to call it. I realize you've given an example that would accept 
any parameters, but that isn't typical.

What if the base class was:

@dataclasses.dataclass
class Foo:
foo: int

def __init__(self, baz):
...
pass

What would the generated Bar.__init__() look like if it were calling the base 
class __init__()? What would get passed to baz?

> So if a dataclass uses a custom __init__, all its child classes must also use 
> a custom __init__

This isn't true. The typical way to handle this is for the derived class to add 
a __post_init__() that calls into the base class's __init__(). This way, you 
can use the normally generated __init__() in the derived class, yet still call 
the base class's __init__() (which presumably you have some knowledge of). If 
that doesn't work for some reason (for example, you strictly require that the 
base class is initialized before the derived class, for some reason), then yes, 
you'd need to write a custom __init__() in the derived class. dataclasses isn't 
designed to handle every case: just the most common ones.

In your case, you could do:

@dataclasses.dataclass
class Bar(Foo):
bar: int

def __post_init__(self):
Foo.__init__(self, baz=self.bar) # or whatever

--
nosy: +eric.smith

___
Python tracker 

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



[issue43785] Remove RLock from BZ2File

2021-04-13 Thread Inada Naoki


Inada Naoki  added the comment:


New changeset 695d47b51e3e197de5448a1eb2f618bef6d59ac8 by Inada Naoki in branch 
'master':
bpo-43785: Update bz2 document (GH-25351)
https://github.com/python/cpython/commit/695d47b51e3e197de5448a1eb2f618bef6d59ac8


--

___
Python tracker 

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



[issue43785] Remove RLock from BZ2File

2021-04-13 Thread Inada Naoki


Change by Inada Naoki :


--
resolution:  -> fixed
stage: patch review -> 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



[issue43810] os.path.abspath returns invalid path (resolves symbolic link)

2021-04-13 Thread Eryk Sun


Eryk Sun  added the comment:

If realpath() resolves too much, you'll have to resolve manually via 
os.path.islink() and os.readlink(). If you need strict resolution, use 
pathlib.Path.resolve(). In strict mode it raises FileNotFoundError if a path 
component doesn't exist. Also, even in non-strict mode, it raises RuntimeError 
for a symlink loop.

--

___
Python tracker 

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



Re: translating external files type thing

2021-04-13 Thread Terry Reedy

On 4/13/2021 4:53 PM, Avi Gross via Python-list wrote:

https://translate.google.com/?sl=is=en=translate

Or, you could do it the hard way.

Kidding aside, there may be a python module you can hand a file name or
contents to and have it do much of the job using some API that may tap into
the above Google resource.


For one chunk of text under 5000 chars, the website is easiest.


Dan specifically suggested importing googletrans ...


The author reverse engineered the undocumented ticket used by the web 
page.  It will work until Google either bans one's IP address or 
disables googletrans by changing the protocol.  Since Google's paid 
service only charges for chars over 500_000 in a month, Google is likely 
better off leaving the protocol alone and only banning users who would 
actually pay if signed up.




-Original Message-
From: Python-list  On
Behalf Of Quentin Bock
Sent: Tuesday, April 13, 2021 3:16 PM
To: python-list@python.org
Subject: translating external files type thing

okay, so I'm making a translating program, and I have files set to be
translated (they're in Icelandic) and I want all of them to be read in
English but I'm not sure how to open the files and translate them at the
same time. I'm also not even sure how to translate an external file to
English from another language.
I can't show code for this because I don't know if it's possible to do what
I'm asking.
Hopefully, this question is understandable Thanks
--
https://mail.python.org/mailman/listinfo/python-list




--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


How does "__doc__ % globals()" work?

2021-04-13 Thread Jaime
Chris and Ethan,

Thank you both for your explanations - as soon as I read them, I understood
where I was going wrong. I also found the mapping key "%(PROGRAM)s" inside
the docstring on line 4 of
https://github.com/python/peps/blob/master/pep2html.py

Thanks again, Jaime.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue43725] Create a release branch ABI stability regression test

2021-04-13 Thread STINNER Victor


STINNER Victor  added the comment:

> I got a false positive on my PR at 
> https://github.com/python/cpython/pull/25318/checks?check_run_id=2308871807

Oh, this CI failure was on Python 3.8.

Since Python 3.9, Python is now built with -fvisibility=hidden to avoid 
exporting symbols which are not explicitly exported. So in 3.9, we no longer 
have to ignore all symbols prefixed by "_Py".

--

___
Python tracker 

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



[issue43725] Create a release branch ABI stability regression test

2021-04-13 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +24127
pull_request: https://github.com/python/cpython/pull/25394

___
Python tracker 

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



[issue43725] Create a release branch ABI stability regression test

2021-04-13 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

I am going to revert the 3.9 PR as 3.9+ is hiding symbols by default.

--

___
Python tracker 

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



[issue43725] Create a release branch ABI stability regression test

2021-04-13 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> $ objdump -T /lib64/libpython3.10.so.1.0|grep 
> _Py_M__importlib_bootstrap_external
# empty output

This was happening on 3.8 Victor:

root@d9c5942e274b:/src# objdump -T libpython3.8.so | grep 
_Py_M__importlib_bootstrap_external
00335740 gDO .rodatab062  Base
_Py_M__importlib_bootstrap_external

--

___
Python tracker 

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



[issue43725] Create a release branch ABI stability regression test

2021-04-13 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> To skip ABI tests? I proposed to ignore ABI changes if they can be ignored 
> safely. But I don't know right now which changes can be ignored or not.

As the situation stands we need to choose on keeping my changes to ignore _Py 
function changes or revert it. Further than that is unexplored land

--

___
Python tracker 

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



[issue43725] Create a release branch ABI stability regression test

2021-04-13 Thread STINNER Victor


STINNER Victor  added the comment:

> Ok, then we need to revert by latest 2 PRs and add a new label or something 
> to skip

To skip ABI tests? I proposed to ignore ABI changes if they can be ignored 
safely. But I don't know right now which changes can be ignored or not.

--

___
Python tracker 

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



[issue43835] Dataclasses don't call base class __init__

2021-04-13 Thread Paul Pinterits


New submission from Paul Pinterits :

It's documented behavior that @dataclass won't generate an __init__ method if 
the class already defines one. It's also documented that a dataclass may 
inherit from another dataclass.

But what happens if you inherit from a dataclass that implements a custom 
__init__? Well, that custom __init__ is never called:

```
import dataclasses

@dataclasses.dataclass
class Foo:
foo: int

def __init__(self, *args, **kwargs):
print('Foo.__init__')  # This is never printed

@dataclasses.dataclass
class Bar(Foo):
bar: int

obj = Bar(1, 2)
print(vars(obj))  # {'foo': 1, 'bar': 2}
```

So if a dataclass uses a custom __init__, all its child classes must also use a 
custom __init__. This is 1) incredibly inconvenient, and 2) bad OOP. A child 
class should (almost) always chain-call its base class's __init__.

--
components: Library (Lib)
messages: 391006
nosy: Paul Pinterits
priority: normal
severity: normal
status: open
title: Dataclasses don't call base class __init__
versions: Python 3.10, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



Re: UI design: combobox or radiobuttons?

2021-04-13 Thread Mirko via Python-list
Am 13.04.2021 um 23:53 schrieb Rich Shepard:
> My applications use environmental data, each of which has to specify
> the
> units (e.g., cm, m, km, ft, yd, mi). With the widget sets I've used
> (wxPython and TKinter) I've always used a combobox with the acceptable
> choices in it. I'm now planning a new application using PyQt5 and it
> occured
> to me that a set of radio buttons would also work.
> 
> While a set of radiobuttons occupies more room on the parent widget
> than
> does a combobox are there any technical or user issues that would
> suggest
> using one over the other?
> 
> TIA,
> 
> Rich

I use radiobuttons if the list of choices is small and static, like
about 2 - 5 fixed entries. Comboboxes are better for larger lists,
or if the user can add own entries, or if there's a chance that the
program needs more entries later.

IME, radiobuttons cause more visual distraction while comboboxes can
be less obvious for less tech-savvy people. OTOH, comboboxes require
two clicks.

For your situation with units, I would probably go for radios if the
user needs to change the units often and combos if radios would make
the view more complex and less obvious.
-- 
https://mail.python.org/mailman/listinfo/python-list


UI design: combobox or radiobuttons?

2021-04-13 Thread Rich Shepard

My applications use environmental data, each of which has to specify the
units (e.g., cm, m, km, ft, yd, mi). With the widget sets I've used
(wxPython and TKinter) I've always used a combobox with the acceptable
choices in it. I'm now planning a new application using PyQt5 and it occured
to me that a set of radio buttons would also work.

While a set of radiobuttons occupies more room on the parent widget than
does a combobox are there any technical or user issues that would suggest
using one over the other?

TIA,

Rich

--
https://mail.python.org/mailman/listinfo/python-list


[issue40137] TODO list when PEP 573 "Module State Access from C Extension Methods" will be implemented

2021-04-13 Thread STINNER Victor


STINNER Victor  added the comment:

I wrote PR 25393 to micro-optimize _PyType_GetModuleByDef(). It reduces the 
overhead from +5.7 ns to +3.4 ns (-2.3 ns).

Well, I didn't check in depth if _PyType_GetModuleByDef() is the only change in 
functools.lru_cache() from Python 3.9 to master.

Compare master to Python 3.9:

Mean +- std dev: [py39] 37.5 ns +- 1.0 ns -> [master] 43.2 ns +- 0.7 ns: 1.15x 
slower

Compare PR 25393 to Python 3.9:

Mean +- std dev: [py39] 37.5 ns +- 1.0 ns -> [inline] 40.9 ns +- 1.0 ns: 1.09x 
slower

Compare PR 25393 to master:

Mean +- std dev: [master] 43.2 ns +- 0.7 ns -> [inline] 40.9 ns +- 1.0 ns: 
1.05x faster

--

___
Python tracker 

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



RE: translating external files type thing

2021-04-13 Thread Avi Gross via Python-list
https://translate.google.com/?sl=is=en=translate

Or, you could do it the hard way.

Kidding aside, there may be a python module you can hand a file name or
contents to and have it do much of the job using some API that may tap into
the above Google resource.

Dan specifically suggested importing googletrans ...

-Original Message-
From: Python-list  On
Behalf Of Quentin Bock
Sent: Tuesday, April 13, 2021 3:16 PM
To: python-list@python.org
Subject: translating external files type thing

okay, so I'm making a translating program, and I have files set to be
translated (they're in Icelandic) and I want all of them to be read in
English but I'm not sure how to open the files and translate them at the
same time. I'm also not even sure how to translate an external file to
English from another language.
I can't show code for this because I don't know if it's possible to do what
I'm asking.
Hopefully, this question is understandable Thanks
--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue40137] TODO list when PEP 573 "Module State Access from C Extension Methods" will be implemented

2021-04-13 Thread STINNER Victor


STINNER Victor  added the comment:

> ./python -m pyperf timeit "from functools import lru_cache; f = 
> lru_cache(lambda: 42)" "f()" --compare-to ../3.9/python
> /home/pablogsal/github/3.9/python: . 2.60 us +- 0.05 us

You misused pyperf timeit: the two statements are run at each iteration of the 
benchmark.

I rerun the benchmark on Linux with PGO+LTO and CPU isolation:

Mean +- std dev: [py39] 37.5 ns +- 1.0 ns -> [master] 43.2 ns +- 0.7 ns: 1.15x 
slower

I understand that adding get_functools_state_by_type() has a cost of +5.7 ns on 
the performance of functions decorated with @lru_cache.

I used the commands:

./configure --enable-optimizations --with-lto
make
./python -m venv env
env/bin/python -m pip install pyperf
./env/bin/python -m pyperf timeit -s "from functools import lru_cache; f = 
lru_cache(lambda: 42)" "f()" -o master.json -v --duplicate=4096

--
stage: patch review -> resolved

___
Python tracker 

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



[issue40137] TODO list when PEP 573 "Module State Access from C Extension Methods" will be implemented

2021-04-13 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +24126
stage: resolved -> patch review
pull_request: https://github.com/python/cpython/pull/25393

___
Python tracker 

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



[issue43833] Unexpected Parsing of Numeric Literals Concatenated with Boolean Operators

2021-04-13 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

One thing we could consider as Serhiy proposed on the mailing list is to emit a 
Syntax Warning. The ambiguous cases are specially scary so I think that makes 
sense

--

___
Python tracker 

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



[issue43833] Unexpected Parsing of Numeric Literals Concatenated with Boolean Operators

2021-04-13 Thread Anthony Sottile


Anthony Sottile  added the comment:

here's quite a few other cases as well -- I'd love for this to be clarified in 
PEP8 such that I can rationalize crafting a rule for it in `pycodestyle` -- 
https://github.com/PyCQA/pycodestyle/issues/371

--
nosy: +Anthony Sottile

___
Python tracker 

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



[issue43833] Unexpected Parsing of Numeric Literals Concatenated with Boolean Operators

2021-04-13 Thread sco1


sco1  added the comment:

Appreciate the additional historical context, I also was pointed to this in the 
documentation: 
https://docs.python.org/3/reference/lexical_analysis.html#whitespace-between-tokens

If a parsing change is undesired from a backwards compatibility standpoint, 
would it be something that could be included in PEP 8?

--

___
Python tracker 

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



Re: translating external files type thing

2021-04-13 Thread Dan Stromberg
Hi.

Does this give you any ideas?

#!/usr/bin/env python3

"""Quick translation program - English to Icelandic."""

# import pprint

import googletrans

# pprint.pprint(googletrans.LANGUAGES)

translator = googletrans.Translator()

with open('input-file', 'r') as file_:
english_text = file_.read()

translated = translator.translate(english_text, src='en', dest='is')

with open('output-file', 'w') as file_:
file_.write(translated.text)


My input-file contains:
This is a test of the emergency broadcast system.

I like the music of Björk.

HTH.

On Tue, Apr 13, 2021 at 12:16 PM Quentin Bock  wrote:

> okay, so I'm making a translating program, and I have files set to be
> translated (they're in Icelandic) and I want all of them to be read in
> English but I'm not sure how to open the files and translate them at the
> same time. I'm also not even sure how to translate an external file
> to English from another language.
> I can't show code for this because I don't know if it's possible to do what
> I'm asking.
> Hopefully, this question is understandable
> Thanks
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue43834] Use context manager in StringIO example

2021-04-13 Thread John Hagen


New submission from John Hagen :

The example for StringIO currently manually closes the object rather than using 
a context manager. Since this is likely the first code that a new user 
encounters and context managers reduce error-prone situations, I think it would 
be helpful to show usage as a context manager.

https://docs.python.org/3/library/io.html#io.StringIO.getvalue

Something like:

import io

with io.StringIO() as output:
output.write('First line.\n')
print('Second line.', file=output)

# Retrieve file contents -- this will be
# 'First line.\nSecond line.\n'
contents = output.getvalue()

# Context manager will automatically close
# object and discard memory buffer --
# .getvalue() will now raise an exception.

--
assignee: docs@python
components: Documentation
messages: 391000
nosy: John Hagen, docs@python
priority: normal
severity: normal
status: open
title: Use context manager in StringIO example
type: enhancement
versions: Python 3.10

___
Python tracker 

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



[issue43833] Unexpected Parsing of Numeric Literals Concatenated with Boolean Operators

2021-04-13 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Precisely because examples like that changing this is a breaking change. Don't 
get me wrong: I would love to change it, but I don't know if is worth the risk

--

___
Python tracker 

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



[issue43833] Unexpected Parsing of Numeric Literals Concatenated with Boolean Operators

2021-04-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Better example:

>>> [0x1for x in (1,2)]
[31]

The code is parsed as [0x1f or x in (1,2)] instead of [0x1 for x in (1,2)] as 
you may expect.

--

___
Python tracker 

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



[issue43833] Unexpected Parsing of Numeric Literals Concatenated with Boolean Operators

2021-04-13 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

We tried changing this IIRC and it broke code in the stdlib (now reformatted) 
so it will break code in the wild. I am not sure the gains are worth it.

--

___
Python tracker 

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



[issue43833] Unexpected Parsing of Numeric Literals Concatenated with Boolean Operators

2021-04-13 Thread Shreyan Avigyan


Shreyan Avigyan  added the comment:

Hi. I'm totally confused about other keywords but I'm a little concerned about 
the "and", "or" operator when used on, not only "int" (also known as "long") 
but also most Python objects other then bool type.

Mostly when used on Python built-in objects "and", "or" keyword returns a very 
peculiar result. The "and" keyword returns the Python object on the left hand 
side while "or" returns the Python object on the right hand side. This applies 
to all Python object, built-in or user-defined, unless it has a specific 
__and__ or __or__ method defined. 

What is actually going on?

--
nosy: +shreyanavigyan

___
Python tracker 

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



[issue43833] Unexpected Parsing of Numeric Literals Concatenated with Boolean Operators

2021-04-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Good example! Similar issue was discussed on the mailing list 3 years ago
(https://mail.python.org/archives/list/python-...@python.org/thread/D2WPCITHG2LBQAP7DBTC6CY26WQUBAKP/#D2WPCITHG2LBQAP7DBTC6CY26WQUBAKP).
 Now with new example it perhaps should be reconsidered.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue43725] Create a release branch ABI stability regression test

2021-04-13 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Ok, then we need to revert by latest 2 PRs and add a new label or something to 
skip

--

___
Python tracker 

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



[issue43833] Unexpected Parsing of Numeric Literals Concatenated with Boolean Operators

2021-04-13 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

This is know behaviour unfortunately and cannot be changed because of backwards 
compatibility.

--
nosy: +pablogsal

___
Python tracker 

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



[issue43811] Run GHA CI with multiple OpenSSL versions

2021-04-13 Thread miss-islington


miss-islington  added the comment:


New changeset a607815eb07582deb3c5818be881a98abe25a100 by Miss Islington (bot) 
in branch '3.8':
[3.8] bpo-43811: Test multiple OpenSSL versions on GHA (GH-25360) (GH-25392)
https://github.com/python/cpython/commit/a607815eb07582deb3c5818be881a98abe25a100


--

___
Python tracker 

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



[issue43833] Unexpected Parsing of Numeric Literals Concatenated with Boolean Operators

2021-04-13 Thread Carl Friedrich Bolz-Tereick


Carl Friedrich Bolz-Tereick  added the comment:

It's not just about keywords. Eg '1x' tokenizes too but then produces a syntax 
error in the parser. Keywords are only special in that they can be used to 
write syntactically meaningful things with these concatenated numbers.

--
nosy: +Carl.Friedrich.Bolz

___
Python tracker 

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



translating external files type thing

2021-04-13 Thread Quentin Bock
okay, so I'm making a translating program, and I have files set to be
translated (they're in Icelandic) and I want all of them to be read in
English but I'm not sure how to open the files and translate them at the
same time. I'm also not even sure how to translate an external file
to English from another language.
I can't show code for this because I don't know if it's possible to do what
I'm asking.
Hopefully, this question is understandable
Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue37179] asyncio loop.start_tls() provide support for TLS in TLS

2021-04-13 Thread Jordan Borean


Jordan Borean  added the comment:

Fantastic thanks, I'll keep watching the issue in the background as it sounds 
like it's under control.

--

___
Python tracker 

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



[issue43811] Run GHA CI with multiple OpenSSL versions

2021-04-13 Thread miss-islington


miss-islington  added the comment:


New changeset 5ce227f3a767e6e44e7c41e0c845a83cfca4 by Miss Islington (bot) 
in branch '3.9':
[3.9] bpo-43811: Test multiple OpenSSL versions on GHA (GH-25360) (GH-25391)
https://github.com/python/cpython/commit/5ce227f3a767e6e44e7c41e0c845a83cfca4


--

___
Python tracker 

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



[issue43833] Unexpected Parsing of Numeric Literals Concatenated with Boolean Operators

2021-04-13 Thread Alistair Muldal


Alistair Muldal  added the comment:

Several other keywords seem to be affected, including `if`, `else`, `is`, and 
`in`

--
nosy: +alimuldal

___
Python tracker 

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



[issue43725] Create a release branch ABI stability regression test

2021-04-13 Thread STINNER Victor


STINNER Victor  added the comment:

In a Python stable version, I would suggest to only ignore an ABI change after 
a manual validation .Otherwise, we can miss real issues.

Well, I expect that at the beginning, we will discover many issues like 
_Py_M__importlib_bootstrap_external ;-)

--

___
Python tracker 

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



[issue43725] Create a release branch ABI stability regression test

2021-04-13 Thread STINNER Victor


STINNER Victor  added the comment:

> We could ignore all functions that start with _Py.

Some symbols starting with _Py are indirectly part of the ABI. Example of 
Include/cpython/pyctype.h:

#define Py_ISLOWER(c)  (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_LOWER)
PyAPI_DATA(const unsigned int) _Py_ctype_table[256];

Even if "_Py_ctype_table" is not directly part of the C API, it's technically 
part of the ABI.

If tomorrow, _Py_ctype_table is truncated to 128 items, it would be an 
incompatible ABI change.

--

___
Python tracker 

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



[issue43725] Create a release branch ABI stability regression test

2021-04-13 Thread STINNER Victor


STINNER Victor  added the comment:

> Oh wow, that's terrible... yet another good reason not to export data values.

_Py_M__importlib_bootstrap_external symbol doesn't seem to be exported. Why is 
it seen as a public symbol?

$ objdump -T /lib64/libpython3.10.so.1.0|grep 
_Py_M__importlib_bootstrap_external
# empty output

--

___
Python tracker 

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



[issue39232] asyncio crashes when tearing down the proactor event loop

2021-04-13 Thread Michael Hall


Change by Michael Hall :


--
versions: +Python 3.10, Python 3.9

___
Python tracker 

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



[issue43833] Unexpected Parsing of Numeric Literals Concatenated with Boolean Operators

2021-04-13 Thread sco1


sco1  added the comment:

Sorry, the bonus, while fun, I don't think is related

--

___
Python tracker 

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



[issue43833] Unexpected Parsing of Numeric Literals Concatenated with Boolean Operators

2021-04-13 Thread Rich rauenzahn


Change by Rich rauenzahn :


--
nosy: +rrauenza

___
Python tracker 

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



[issue43831] sqlite: convert_timestamp raises ValueError for empty columns

2021-04-13 Thread Erlend Egeberg Aasland

Erlend Egeberg Aasland  added the comment:

Hi Lumír, thank you for your report.

This is a duplicate of bpo-43752.

The bugfix currently is awaiting review, and will be included in python3.10b1 
(expected in approx. three weeks).

--
nosy: +berker.peksag, erlendaasland

___
Python tracker 

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



[issue43833] Unexpected Parsing of Numeric Literals Concatenated with Boolean Operators

2021-04-13 Thread Ned Batchelder


Change by Ned Batchelder :


--
nosy: +nedbat

___
Python tracker 

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



[issue43810] os.path.abspath returns invalid path (resolves symbolic link)

2021-04-13 Thread Rene Visser

Rene Visser  added the comment:

Thanks Eryk for your fast response. Apparently I somehow skipped the remark
about symbolic links in combination with abspath. Thank you for pointing
this out and apologies for wasting some of your time!!
Best wishes, Rene Visser

On Mon, Apr 12, 2021 at 7:40 AM Eryk Sun  wrote:

>
> Eryk Sun  added the comment:
>
> In POSIX, os.path.abspath(p) is normpath(join(os.getcwd(), p)). normpath()
> doesn't touch the filesystem, and it's documented that its "string
> manipulation may change the meaning of a path that contains symbolic
> links". You can use os.path.realpath() to resolve symbolic links in a path.
>
> --
> nosy: +eryksun
> resolution:  -> not a bug
> stage:  -> resolved
> status: open -> closed
>
> ___
> Python tracker 
> 
> ___
>

-- 

---

René Visser
Stuttgart, Germany
email: renevis...@gmail.com

---

--

___
Python tracker 

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



[issue43833] Unexpected Parsing of Numeric Literals Concatenated with Boolean Operators

2021-04-13 Thread sco1


New submission from sco1 :

Came across this riddle today:

>>> [0x_for x in (1, 2, 3)]
[15]

Initially I thought this was related to PEP 515 but the unexpected behavior 
extends to simpler examples as well, such as:

>>> x = 5
>>> 123or x
123
>>> 123and x
5

I'm not familiar enough with C to understand why this is being parsed/tokenized 
this way, but this seems like it should instead be a SyntaxError. This appears 
to be fairly old behavior, as the non-underscored version works back to at 
least 2.7.

And a bonus:

>>> 0x1decade or more
31378142

--
messages: 390981
nosy: sco1
priority: normal
severity: normal
status: open
title: Unexpected Parsing of Numeric Literals Concatenated with Boolean 
Operators
type: behavior
versions: Python 3.10, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



Re: Comparing text strings

2021-04-13 Thread Rich Shepard

On Tue, 13 Apr 2021, jak wrote:


If I understand your problem correctly, the problem would be dealing with
numbers as such in file names. This is just a track but it might help you.
This example splits filenames into strings and numbers into tuples,
appends the tuple into a list, and then sorts the list:


jak,

Yes, it would be the version and build numbers that differ when two files
have the same initial string (application name).

Thanks very much,

Rich


--
https://mail.python.org/mailman/listinfo/python-list


Hypertag - new language for HTML templating with Django support (announcement)

2021-04-13 Thread Marcin Wojnarski
Hello everyone,



Hypertag (http://hypertag.io/) is a new language for document generation and 
HTML templating that has been released recently. Inspired by indentation-based 
template languages (Slim, Haml, Shpaml), it provides clean, readable syntax and 
multiple original features: 



- native custom tags inside scripts

- DOM tree manipulation during document construction

- complex expressions with all Python operators

- control blocks, local variables

- Python-like granular imports

- pipeline syntax and filters

- full Django integration

- and more...



Hypertag enhances modularity and code reuse inside presentation code to an 
unprecedented degree. Available on GitHub and PyPI:



- https://github.com/mwojnars/hypertag

- https://pypi.org/project/hypertag-lang/



Language Reference: 



- http://hypertag.io/



Install from PyPI as "hypertag-lang".



Regards,



-- 

Marcin Wojnarski, Founder and CEO at Paperity, http://www.paperity.org
 http://www.linkedin.com/in/marcinwojnarski
 https://www.facebook.com/Paperity
 https://twitter.com/Paperity
 
 Paperity. Open science aggregated.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue43811] Run GHA CI with multiple OpenSSL versions

2021-04-13 Thread miss-islington


Change by miss-islington :


--
pull_requests: +24125
pull_request: https://github.com/python/cpython/pull/25392

___
Python tracker 

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



[issue43811] Run GHA CI with multiple OpenSSL versions

2021-04-13 Thread miss-islington


Change by miss-islington :


--
pull_requests: +24124
pull_request: https://github.com/python/cpython/pull/25391

___
Python tracker 

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



[issue43811] Run GHA CI with multiple OpenSSL versions

2021-04-13 Thread miss-islington


miss-islington  added the comment:


New changeset 8fa1489365e7af8b90286c97db55a2dc60a05cde by Christian Heimes in 
branch 'master':
bpo-43811: Test multiple OpenSSL versions on GHA (GH-25360)
https://github.com/python/cpython/commit/8fa1489365e7af8b90286c97db55a2dc60a05cde


--
nosy: +miss-islington

___
Python tracker 

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



Re: Comparing text strings

2021-04-13 Thread jak

Il 13/04/2021 01:11, Rich Shepard ha scritto:

I'm running Slackware64-14.2 and keep a list of installed packages. When a
package is upgraded I want to remove the earlier version, and I've not
before written a script like this. Could there be a module or tool that
already exists to do this? If not, which string function would be best
suited to the task?

Here's an example:
atftp-0.7.2-x86_64-2_SBo.tgz
atftp-0.7.4-x86_64-1_SBo.tgz

and there are others like this. I want the python3 script to remove the
first one. Tools like like 'find' or 'sort -u' won't work because while the
file name is the same the version or build numbers differ.

All suggestions welcome.

Rich



If I understand your problem correctly, the problem would be dealing 
with numbers as such in file names. This is just a track but it might 
help you. This example splits filenames into strings and numbers into 
tuples, appends the tuple into a list, and then sorts the list:


files = ['atftp-0.7.4-x86_64-2_SBo.tgz', 'atftp-0.7.2-x86_64-1_SBo.tgz']
digit = None
da = ''
tfn = tuple()
ltafn = list()
for f in files:
for c in f:
if str(c).isdigit():
if not digit:
if len(da) > 0:
tfn += (da,)
da = ''
digit = True
da += c
else:
da += c
else:
if digit:
if len(da) > 0:
tfn += (int(da),)
da = ''
digit = False
da += c
else:
da += c
if len(da) > 0:
if da.isdigit():
tfn += (int(da),)
else:
tfn += (da,)
da = ''
ltafn += [tfn, ]
tfn = ()

ltafn.sort()

for t in files:
print(t)
print()
for t in ltafn:
nn = ''
for f in t:
nn += str(f)
print(nn)
--
https://mail.python.org/mailman/listinfo/python-list


[issue41515] typing.get_type_hints generates KeyError

2021-04-13 Thread STINNER Victor


STINNER Victor  added the comment:

I see that all PRs are merged, and the CI issue is fixed as well. I close the 
issue.

commit eb77133564d74eb09ed63872a69b9827d4841b49
Author: Karthikeyan Singaravelan 
Date:   Tue Apr 13 19:24:23 2021 +0530

bpo41515: Fix assert in test which throws SyntaxWarning. (#25379)

--
resolution:  -> fixed
stage: patch review -> 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



[issue14811] decoding_fgets() truncates long lines and fails with a SyntaxError("Non-UTF-8 code starting with...")

2021-04-13 Thread STINNER Victor


STINNER Victor  added the comment:

With https://bugs.python.org/issue14811#msg160706 I get a SyntaxError on Python 
3.7, 3.8, 3.9 and 3.10.0a6. But I don't get an error on the master branch 
(Python 3.10.0a7+).

Eryk:
> The latest alpha release, 3.10a7, includes your rewrite of the tokenizer, and 
> in that case t33a.py no longer fails in Windows.

Oh ok, this issue was fixed by the following commit which is part of v3.10.0a7 
release:

commit 261a452a1300eeeae1428ffd6e6623329c085e2c
Author: Pablo Galindo 
Date:   Sun Mar 28 23:48:05 2021 +0100

bpo-25643: Refactor the C tokenizer into smaller, logical units (GH-25050)

--
resolution:  -> duplicate
stage: needs patch -> resolved
status: open -> closed
superseder:  -> Python tokenizer rewriting

___
Python tracker 

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



Re: ipython display figure

2021-04-13 Thread Stestagg
I'm guessing here a little bit, but it looks like the author expects you to
run this code in a jupyter notebook, rather than in an ipython interactive
console.

The jupyter and ipython projects are related (the same?) which can cause
some confusion, but if you run the code you shared in a jupyter lab
environment, then the SVG should display.

As an example, you should be able to view the expected SVG in the following
google colab book:

https://colab.research.google.com/drive/10KL9mV92L8yPe_5wL089C-m6i0N8ct7Q?usp=sharing

 Steve

On Tue, Apr 13, 2021 at 3:12 PM Peng Yu  wrote:

> Hi,
>
> https://www.fuzzingbook.org/html/Grammars.html
>
> I am trying to follow an example on the above page. But it does not
> show a figure. Could anybody let me know how to display the figure?
>
> $  ipython3
> Python 3.8.0 (v3.8.0:fa919fdf25, Oct 14 2019, 10:23:27)
> Type 'copyright', 'credits' or 'license' for more information
> IPython 7.22.0 -- An enhanced Interactive Python. Type '?' for help.
>
> [ins] In [1]: from fuzzingbook.Grammars import *
>
> [ins] In [2]: from IPython.display import SVG, display
>
> [ins] In [3]:
> SVG(show_diagram(syntax_diagram_expr(EXPR_GRAMMAR[''][0])))
> Out[3]: 
>
> --
> Regards,
> Peng
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue43797] Improve syntax error for invalid comparisons

2021-04-13 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 30ed93bfec5dfa7ee05982e2df8fd810f3f49305 by Pablo Galindo in 
branch 'master':
bpo-43797: Handle correctly invalid assignments inside function calls and 
generators (GH-25390)
https://github.com/python/cpython/commit/30ed93bfec5dfa7ee05982e2df8fd810f3f49305


--

___
Python tracker 

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



Re: Immutable view classes - inherit from dict or from Mapping?

2021-04-13 Thread Serhiy Storchaka
13.04.21 15:47, Peter Otten пише:
> As to the | operator, maybe it could be added to Mapping?

The | operator returns a new instance, but constructor is not a part of
the Mapping interface. You cannot make a general implementation, and
making __or__ an abstract method will break all existing Mapping
interface implementations which do not have the __or__ method.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Immutable view classes - inherit from dict or from Mapping?

2021-04-13 Thread Serhiy Storchaka
12.04.21 19:01, Andreas R Maier пише:
> Hi,
> I have written some classes that represent immutable views on collections 
> (see "immutable-views" package on Pypi).
> 
> Currently, these view classes inherit from the abstract collection classes 
> such as Mapping, Sequence, Set. However, they implement the read-only methods 
> of dict, list and set, which provides some more methods compared to the 
> abstract collection classes. For example, class "dict" provides copy() or 
> __reversed__() and the newer OR-operator methods all of which are not defined 
> on the abstract class "Mapping".
> 
> Note that the view classes do not provide any of the modifying methods of 
> "dict" and "list", because after all the views are supposed to be immutable.
> 
> My question is, should the dict view class inherit from Mapping or from dict, 
> and likewise, should the list view class inherit from Sequence or from list?

If it is a view, and represents a data stored in another object, it
cannot be a subclass of concrete collection class.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Comparing text strings

2021-04-13 Thread Grant Edwards
On 2021-04-12, 2qdxy4rzwzuui...@potatochowder.com 
<2qdxy4rzwzuui...@potatochowder.com> wrote:

> I don't know whether or how Slackware handles "compound" package names
> (e.g., python-flask), but at some point, you're going to have to pull
> apart (aka---gasp--parse), the package names to come up with the name
> itself and the version (and the architecture, etc.), compare the name
> parts to find the "duplicates," and then compare the versions (and maybe
> the build number) to eliminate the lesser ones.
>
> You'll also have to watch for the transitions from, say, 0.9 to 0.10, or
> from 1.0rc2 to 1.0, which may not sort simply.

Indeed. Sorting version numbers is very dark magic, and you'll need to
know way more than you want to about the version numbering conventions
in your distro. There may be all sorts of exceptions and special cases
(like handling an rcNN version-number suffix as mentioned above).

--
Grant



-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   >